﻿using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using CE.User;
using CE.Global;
using CE.Database;
using CE.Provider;
using CE.TravelInsurance;
using CE.Company;
using CE.Mail;
using CE.InputOut;
using CE.AreaCountry;
using CE.Image;

public partial class travel_insurance_resultsdetails : System.Web.UI.Page
{
    private Int32 RowCount = 0;

    //protected void Page_Init(object sender, EventArgs e)
    //{
    //    if (Session["TASelected"] == null)
    //    {
    //        //Response.Redirect("results.aspx");
    //        //BackToResultsMainPage();
    //        BackToSearchPage();
    //    }
    //    else
    //    {
    //        ResultsQuotesDataBind();
    //    }

    //}

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["emtaid"] != null)
        {
            if (Request.QueryString["emtaid"].ToString() != "")
            {
                Session[General.TAId] = Request.QueryString["emtaid"].ToString();
                GetQuotesAgain("", 1);
            }
        }

        if (Session["TASelected"] == null || Session[General.TAId] == null)
        {
            BackToSearchPage();
        }

        if (!IsPostBack)
        {
            if (Request.IsSecureConnection)
            {
                string redirectUrl = Request.Url.ToString().Replace("https:", "http:");
                Response.Redirect(redirectUrl);
            }

           
            //if (Request.UrlReferrer == null)
            //{
            //    Response.Redirect("travel-quote.aspx");
            //}

            if (Session["TASelected"] == null)
            {
                //Response.Redirect("results.aspx");
                //BackToResultsMainPage();
                BackToSearchPage();
            }

            if (Session[General.TAId] != null)
            {
                if (Session["PlanType"] != null)
                {
                    inputPlanType.Value = Session["PlanType"].ToString();
                }
                LoadSummary();

                ResultsQuotesDataBind();
            }

          
            inputUserId.Value = "0";
            if (Session[General.UserId] != null)
            {
                if (Session[General.UserId].ToString() != "")
                {
                    inputUserId.Value = Session[General.UserId].ToString();
                }
            }
            Session[General.TAResultId] = null;
            Session[General.ViewedDetailsId] = LogUserViewedHistory().ToString();

            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
                Convert.ToInt32(CE.Global.CEUserType.Provider))
            {
                txtFullName.ReadOnly = false;
                txtMobileNo.IsReadOnly = false;
                txtEmail.ReadOnly = false;
            }
            else
            {
                if (Session[General.TAUserName] != null)
                {
                    if (Session[General.TAUserName].ToString() != "")
                    {
                        txtFullName.Text = Session[General.TAUserName].ToString();                       
                    }
                }

                if (Session[General.TAPhoneNo] != null)
                {
                    txtMobileNo.PhoneNo = Session[General.TAPhoneNo].ToString();
                }

                if (Session[General.TAEmail] != null)
                {
                    txtEmail.Text = Session[General.TAEmail].ToString();
                }


                if (Session[General.UserId] != null)
                {
                    if (Session[General.UserName] != null)
                    {
                        if (Session[General.UserName].ToString() != "")
                        {
                            txtFullName.Text = Session[General.UserName].ToString();
                            txtMobileNo.PhoneNo = Session[General.UserPhoneNo].ToString();
                            txtEmail.Text = Session[General.UserEmail].ToString();

                            txtFullName.ReadOnly = true;
                            txtMobileNo.IsReadOnly = true;
                            txtEmail.ReadOnly = true;
                        }
                    }
                    else if (Session[General.TAUserName] != null)
                    {
                        if (Session[General.TAUserName].ToString() != "")
                        {
                            txtFullName.Text = Session[General.TAUserName].ToString();
                            txtMobileNo.PhoneNo = Session[General.TAPhoneNo].ToString();
                            txtEmail.Text = Session[General.TAEmail].ToString();

                            txtFullName.ReadOnly = true;
                            txtMobileNo.IsReadOnly = true;
                            txtEmail.ReadOnly = true;
                        }
                    }
                }

                else
                {
                    txtFullName.ReadOnly = false;
                    txtMobileNo.IsReadOnly = false;
                    txtEmail.ReadOnly = false;
                }
            }

        }

    }

    private void BackToSearchPage()
    {
        if (Request.QueryString["pid"] != null)
        {
            if (Request.QueryString["pid"].ToString() != "")
            {
                Response.Redirect("~/travel-insurance/travel-quote.aspx?pid=" + Request.QueryString["pid"].ToString());
            }
            else
            {
                Response.Redirect("~/travel-insurance/");
            }
        }
        else
        {
            Response.Redirect("~/travel-insurance/");
        }
    }

    private void BackToResultsMainPage()
    {
        if (Request.QueryString["pid"] != null)
        {
            if (Request.QueryString["pid"].ToString() != "")
            {
                Response.Redirect("~/travel-insurance/results.aspx?pid=" + Request.QueryString["pid"].ToString());
            }
            else
            {
                Response.Redirect("~/travel-insurance/results.aspx");
            }
        }
        else
        {
            Response.Redirect("~/travel-insurance/results.aspx");
        }
    }

    private Int64 LogUserViewedHistory()
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        //Sakthi on 15 Feb 2011 Command
        //return _userviewdb.LogViewedHistory("TA", Request, "Travel Insurance results quotes one.");
        return _userviewdb.LogResultViewedHistory("TA", Request, "Travel Insurance results quotes one.");
    }

    private void LogUserSelectHistory(string CoverType, Int64 ResultId, Int64 CompanyId)
    {
        UserSelectHistoryDB _userselectdb = new UserSelectHistoryDB();
        if (CoverType.ToLower() == "ind")
        {
            _userselectdb.LogUserSelectHistory("TA", Request.Browser.Type, Request.UserHostAddress, "TAIND", ResultId, CompanyId);
        }
        else if (CoverType.ToLower() == "ins")
        {
            _userselectdb.LogUserSelectHistory("TA", Request.Browser.Type, Request.UserHostAddress, "TAINDSP", ResultId, CompanyId);
        }
        else
        {
            _userselectdb.LogUserSelectHistory("TA", Request.Browser.Type, Request.UserHostAddress, "TAFML", ResultId, CompanyId);
        }

    }

    protected void LoadSummary()
    {
        Int64 TAId = 0;

        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();

        if (Session[General.TAId] != null)
            TAId = Convert.ToInt64(Session[General.TAId]);

        _taapplicantsearch = _taapplicantsearchdb.GetTAApplicantSearchItem(TAId);

        if (_taapplicantsearch != null)
        {

            lblTripType.Text = GetCoverage(_taapplicantsearch.TripType.ToString());
            lblPolicy.Text = GetPolicy(_taapplicantsearch.PlanType.ToString());
            lblTravelDate.Text = String.Format("{0:dd/MM/yyyy} To {1:dd/MM/yyyy}", _taapplicantsearch.StartDate, _taapplicantsearch.EndDate);
            lblTravellers.Text = (_taapplicantsearch.NoofChilds + _taapplicantsearch.NoofAdults).ToString();

            inputNoOfAdult.Value = _taapplicantsearch.NoofAdults.ToString();

            if (_taapplicantsearch.AreaID != 0)
                lblDestination.Text = GetAreaName(_taapplicantsearch.AreaID);
            else
                lblDestination.Text = GetCountryName(_taapplicantsearch.CountryID);

            ddlCoverage.SelectedValue = _taapplicantsearch.CoverageLevel;

        }
    }

    protected string GetAreaName(Int64 areaid)
    {
        string Area = "";

        AreaInfo _areainfo = new AreaInfo();
        AreaInfoDB _areainfodb = new AreaInfoDB();

        _areainfo = _areainfodb.GetAreaInfo(areaid);

        Area = _areainfo.Description;

        return Area;

    }

    protected string GetCountryName(Int64 countryid)
    {
        string Country = "";

        CountryInfo _countryinfo = new CountryInfo();
        CountryInfoDB _countryinfodb = new CountryInfoDB();

        _countryinfo = _countryinfodb.GetCountryInfo(countryid);

        Country = _countryinfo.Description;

        return Country;

    }

    protected string GetPolicy(string covertype)
    {
        string policy = "family";

        if (covertype == "IND")
        {
            policy = "Individual";
        }
        else if (covertype == "INS")
        {
            policy = "Individual + Spouse";
        }
        else if (covertype == "INC")
        {
            policy = "Individual + Child";
        }
        else if (covertype == "FML")
        {
            policy = "Family";
        }

        return policy;
    }

    protected string GetCoverage(string coverage)
    {
        string cover = "Single Trip";

        if (coverage == "A")
            cover = "Annual Multi-trip";

        return cover;
    }

    private void ResultsQuotesDataBind()
    {
        if (Session[General.TAId] == null)
        {
            //Response.Redirect("~/travel-insurance/");
            BackToSearchPage();
        }

        GetResultDetails();

    }

    private void GetResultDetails()
    {
        if (Session[General.TAId] != null)
        {
            if (Cache["TAResultsQuotes" + Session[General.TAId].ToString()] != null)
            {
                DataView dv = new DataView((DataTable)Cache["TAResultsQuotes" + Session[General.TAId].ToString()]);

                //check paging
                int totalPlans = dv.Table.Rows.Count;

                if (totalPlans > 7)
                {
                    if (!lnkbtnPage1.Enabled) //default 1st page
                    {
                        lnkbtnPrev.Attributes.Add("class", "prev disabled");
                        lnkbtnPage1.Attributes.Add("class", "pagestat");
                        lnkbtnPage2.Attributes.Add("class", "");
                        lnkbtnNex.Attributes.Add("class", "next ");

                        lnkbtnPrevBottom.Attributes.Add("class", "prev disabled");
                        lnkbtnPage1Bottom.Attributes.Add("class", "pagestat");
                        lnkbtnPage2Bottom.Attributes.Add("class", "");
                        lnkbtnNexBottom.Attributes.Add("class", "next ");

                        lblResultsDisplay.Text = "1 to 7 of " + totalPlans.ToString();                     
                    }
                    else
                    {
                        lnkbtnPrev.Attributes.Add("class", "prev ");
                        lnkbtnPage1.Attributes.Add("class", "");
                        lnkbtnPage2.Attributes.Add("class", "pagestat");
                        lnkbtnNex.Attributes.Add("class", "next disabled");

                        lnkbtnPrevBottom.Attributes.Add("class", "prev ");
                        lnkbtnPage1Bottom.Attributes.Add("class", "");
                        lnkbtnPage2Bottom.Attributes.Add("class", "pagestat");
                        lnkbtnNexBottom.Attributes.Add("class", "next disabled");

                        lblResultsDisplay.Text = "8 to " + totalPlans.ToString() + " of " + totalPlans.ToString();                     
                    }
                    lblResultsDisplayBottom.Text = lblResultsDisplay.Text;
                }
                else
                {
                    lnkbtnPrev.Enabled = false;
                    lnkbtnPage1.Enabled = false;
                    lnkbtnPage2.Enabled = false;
                    lnkbtnNex.Enabled = false;

                    lnkbtnPrevBottom.Enabled = false;
                    lnkbtnPage1Bottom.Enabled = false;
                    lnkbtnPage2Bottom.Enabled = false;
                    lnkbtnNexBottom.Enabled = false;

                    lnkbtnPrev.Attributes.Add("class", "prev disabled");
                    lnkbtnPage1.Attributes.Add("class", "disabled");
                    lnkbtnPage2.Attributes.Add("class", "disabled");
                    lnkbtnNex.Attributes.Add("class", "next disabled");

                    lnkbtnPrevBottom.Attributes.Add("class", "prev disabled");
                    lnkbtnPage1Bottom.Attributes.Add("class", "disabled");
                    lnkbtnPage2Bottom.Attributes.Add("class", "disabled");
                    lnkbtnNexBottom.Attributes.Add("class", "next disabled");

                    lblResultsDisplay.Text = "1 to " + totalPlans.ToString() + " of " + totalPlans.ToString();
                    lblResultsDisplayBottom.Text = lblResultsDisplay.Text;
                }

                

                string TATempResultId = Session["TASelected"].ToString();

                dv.RowFilter = " TAInsID in (" + TATempResultId.Remove(TATempResultId.Length - 1, 1) + ")";
                DataTable dtFiltered = dv.ToTable();
                if (Cache["TAResultsQuotes" + Session[General.TAId].ToString()] != null)
                {

                    int rowCount = dtFiltered.Rows.Count;

                    for (int iRows = 0; iRows < rowCount; iRows++)
                    {
                        string _providercompanyid = dtFiltered.Rows[iRows]["ProviderCompanyId"].ToString();

                        //top
                        HtmlTableCell tcTop = new HtmlTableCell();
                        tcTop.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divTop = new HtmlGenericControl("div");

                        HtmlGenericControl divTop1 = new HtmlGenericControl("div");
                        divTop1.Attributes.Add("class", "curvetopleft left");

                        HtmlGenericControl divTop2 = new HtmlGenericControl("div");
                        divTop2.Attributes.Add("class", "curvetopright right");

                        divTop.Controls.Add(divTop1);
                        divTop.Controls.Add(divTop2);

                        tcTop.Controls.Add(divTop);
                        trTop.Controls.Add(tcTop);

                        //Provider Image Logo
                        HtmlTableCell tcProvider = new HtmlTableCell();
                        tcProvider.Attributes.Add("class", "bg_grey_2 h50px pad4px");
                        Image imgCompanyLogo = new Image();

                        //if (dtFiltered.Rows.Count == 2)
                        //{
                        //    imgCompanyLogo.Width = 140;
                        //}
                        //else if (dtFiltered.Rows.Count == 3)
                        //{
                        //    imgCompanyLogo.Width = 130;
                        //}
                        //else if (dtFiltered.Rows.Count == 4)
                        //{
                        //    imgCompanyLogo.Width = 115;
                        //}
                        //else if (dtFiltered.Rows.Count == 5)
                        //{
                        //    imgCompanyLogo.Width = 100;
                        //}
                        //else if (dtFiltered.Rows.Count == 6)
                        //{
                        //    imgCompanyLogo.Width = 85;
                        //}
                        //else if (dtFiltered.Rows.Count == 7)
                        //{
                        //    imgCompanyLogo.Width = 85;
                        //}

                        imgCompanyLogo.Width = 85;

                        //imgCompanyLogo.ImageUrl = dtFiltered.Rows[iRows]["CompanyLogoUrl"].ToString();

                        if (_providercompanyid == "23")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/hsbc.png";
                        }
                        else if (_providercompanyid == "24")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/rsa.png";
                        }
                        else if (_providercompanyid == "29")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/liberty.png";
                        }
                        else if (_providercompanyid == "30")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/etiqa.png";
                        }
                        else if (_providercompanyid == "31")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/chartis.png";
                        }
                        else if (_providercompanyid == "34")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/chinataiping.png";
                        }
                        else if (_providercompanyid == "35")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/eq.png";
                        }
                        else if (_providercompanyid == "36")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/ace.png";
                        }
                        else if (_providercompanyid == "37")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/1cover.png";
                        }
                        else if (_providercompanyid == "38")
                        {
                            imgCompanyLogo.ImageUrl = "~/images/public/logo/directasia.png";
                        }

                        int iTopWidth = 100 / (rowCount + 1);
                        tcProvider.Width = iTopWidth.ToString() + "%";
                        tcProvider.Controls.Add(imgCompanyLogo);
                        trProvider.Controls.Add(tcProvider);

                        //PlanName
                        HtmlTableCell tcPlan = new HtmlTableCell();
                        tcPlan.Attributes.Add("class", "bg_grey_3 border2pxdotb pad4px white");
                        tcPlan.InnerHtml = "<strong>" + dtFiltered.Rows[iRows]["planname"].ToString() + "</strong>";

                        trPlan.Controls.Add(tcPlan);

                        //Premium
                        HtmlTableCell tcPrice = new HtmlTableCell();
                        tcPrice.Attributes.Add("class", "bg_grey_4 h50px border1pxdotb_dark pad4px");
                        HtmlGenericControl divPrice = new HtmlGenericControl("div");
                        divPrice.Attributes.Add("class", "price");

                        String annualpremium = "";
                        annualpremium = String.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()));

                        string TripType = "S";

                        if (Session["TripType"] != null)
                        {
                            TripType = Session["TripType"].ToString();
                        }

                        //Check for PROMOS
                        Int32 promodiscount = GetPromoDiscount(_providercompanyid);
                            Image imgPromo = new Image();
                        if (promodiscount > 0)
                        {
                            //if (_providercompanyid == "23" && TripType == "A")
                            //{

                            //    imgPromo.ImageUrl = "~/images/promo/bag-ico.gif";
                            //    imgPromo.Visible = true;
                            //}
                            //else 
                            //if (_providercompanyid == "24" && TripType != "S")
                            //{
                            //    //promodiscount = 15; ORGINAL @ 28/May/2012
                            //    promodiscount = 20; //PHYO CHANGED @ 28/May/2012 2:41 PM
                            //}

                            //if ((_providercompanyid == "29" && TripType == "S") || _providercompanyid != "29")
                            //{
                            //    annualpremium = string.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()));
                            //    annualpremium += " <s>" + string.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()) / (Convert.ToDouble(100 - promodiscount) / 100)) + "</s>";
                            //}
                            if (_providercompanyid == "29")
                            {
                                annualpremium = string.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()));
                                annualpremium += " <s>" + string.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()) / (Convert.ToDouble(100 - promodiscount) / 100)) + "</s>";
                            }
                        }


                        //Ace 40% discount
                        //DateTime dt = CE.Global.General.GetUTCDateTime();
                        //Int64 iDate = Convert.ToInt64(String.Format("{0:yMMddhhmm}", dt));

                        //Int64 PromoStart = Convert.ToInt64(CE.Configuration.MyConfigurationManager.GetAppSettingValue("TravelACEPromoStart"));
                        //Int64 PromoEnd = Convert.ToInt64(CE.Configuration.MyConfigurationManager.GetAppSettingValue("TravelACEPromoEnd"));

                        //if (iDate >= PromoStart && iDate < PromoEnd)
                        //{
                        //    if (_providercompanyid == "36" && TripType == "S")
                        //    {
                        //        double _original = Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()) / 0.6;
                        //        annualpremium = "<small>" + String.Format("{0:c}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString())) + "</small>";
                        //        annualpremium += "  <s>" + String.Format("{0:c}", _original) + "</s>";

                        //    }
                        //}


                        divPrice.InnerHtml = annualpremium;

                        tcPrice.Controls.Add(divPrice);

                        if (promodiscount > 0 && _providercompanyid == "23" && TripType == "A")
                        {
                            tcProvider.Controls.Add(imgPromo);
                        }

                        trPrice.Controls.Add(tcPrice);

                        //Personal Accident adult
                        HtmlTableCell tcPAadult = new HtmlTableCell();
                        tcPAadult.Attributes.Add("class", "bg_grey_3  pad4px");

                        //if (_providercompanyid == "34")
                        //{
                        //    HyperLink hplnkPA = new HyperLink();
                        //    hplnkPA.ImageUrl = "~/images/icon/pdf.png";
                        //    hplnkPA.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                        //    hplnkPA.Target = "_blank";

                        //    tcPAadult.Controls.Add(hplnkPA);

                        //}
                        //else
                        //{
                            float _fPAadult = 0;
                            if (dtFiltered.Rows[iRows]["DTPD_LessYr70"].ToString() != "")
                            {
                                _fPAadult = Convert.ToSingle(dtFiltered.Rows[iRows]["DTPD_LessYr70"].ToString());
                            }

                            if (_fPAadult > 0.0f)
                            {
                                string _PAadultAmount = String.Format("${0:0,0}", _fPAadult);
                                tcPAadult.InnerHtml = _PAadultAmount;
                            }
                            else
                            {
                                Image imgPAadult = new Image();
                                imgPAadult.ImageUrl = "~/images/icon/X.png";
                                tcPAadult.Controls.Add(imgPAadult);
                            }
                        //}

                        tcPAadult.Width = iTopWidth.ToString() + "%";

                        trPAadult.Controls.Add(tcPAadult);


                        //Personal Accident >70
                        HtmlTableCell tcPA70 = new HtmlTableCell();
                        tcPA70.Attributes.Add("class", "bg_grey_2 border1pxdotb_light pad4px");

                        //if (_providercompanyid == "34")
                        //{
                        //    HyperLink hplnkPA70 = new HyperLink();
                        //    hplnkPA70.ImageUrl = "~/images/icon/pdf.png";
                        //    hplnkPA70.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                        //    hplnkPA70.Target = "_blank";

                        //    tcPA70.Controls.Add(hplnkPA70);
                        //}
                        //else
                        //{
                            float _fPA70 = 0;
                            if (dtFiltered.Rows[iRows]["DTPD_AboveYr70"].ToString() != "")
                            {
                                _fPA70 = Convert.ToSingle(dtFiltered.Rows[iRows]["DTPD_AboveYr70"].ToString());
                            }

                            if (_fPA70 > 0.0f)
                            {
                                string _PA70 = String.Format("${0:0,0}", _fPA70);
                                tcPA70.InnerHtml = _PA70;
                            }
                            else
                            {
                                Image imgPA70 = new Image();
                                imgPA70.ImageUrl = "~/images/icon/X.png";
                                tcPA70.Controls.Add(imgPA70);
                            }
                        //}
                        trPA70.Controls.Add(tcPA70);

                        //Double Indemnity adult
                        HtmlTableCell tcDIadult = new HtmlTableCell();
                        tcDIadult.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkDI = new HyperLink();
                            hplnkDI.ImageUrl = "~/images/icon/pdf.png";
                            hplnkDI.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkDI.Target = "_blank";

                            tcDIadult.Controls.Add(hplnkDI);
                        }
                        else
                        {
                            float _fDIadult = 0;
                            if (dtFiltered.Rows[iRows]["DIPC_LessYr70"].ToString() != "")
                            {
                                _fDIadult = Convert.ToSingle(dtFiltered.Rows[iRows]["DIPC_LessYr70"].ToString());
                            }

                            if (_fDIadult > 0.0f)
                            {
                                string _DIadult = String.Format("${0:0,0}", _fDIadult);
                                tcDIadult.InnerHtml = _DIadult;
                            }
                            else
                            {
                                Image imgDIadult = new Image();
                                imgDIadult.ImageUrl = "~/images/icon/X.png";
                                tcDIadult.Controls.Add(imgDIadult);
                            }
                        }

                        trDoubleIadult.Controls.Add(tcDIadult);

                        //Double Indemnity >70
                        HtmlTableCell tcDoubleI70 = new HtmlTableCell();
                        tcDoubleI70.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkDI70 = new HyperLink();
                            hplnkDI70.ImageUrl = "~/images/icon/pdf.png";
                            hplnkDI70.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkDI70.Target = "_blank";

                            tcDoubleI70.Controls.Add(hplnkDI70);
                        }
                        else
                        {
                            float _fDI70 = 0;
                            if (dtFiltered.Rows[iRows]["DIPC_AboveYr70"].ToString() != "")
                            {
                                _fDI70 = Convert.ToSingle(dtFiltered.Rows[iRows]["DIPC_AboveYr70"].ToString());
                            }

                            if (_fDI70 > 0.0f)
                            {
                                string _DI70 = String.Format("${0:0,0}", _fDI70);
                                tcDoubleI70.InnerHtml = _DI70;
                            }
                            else
                            {
                                Image imgDI70 = new Image();
                                imgDI70.ImageUrl = "~/images/icon/X.png";
                                tcDoubleI70.Controls.Add(imgDI70);
                            }
                        }

                        trDoubleI70.Controls.Add(tcDoubleI70);

                        //Med Expenses adult
                        HtmlTableCell tcMedExpAdult = new HtmlTableCell();
                        tcMedExpAdult.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkMedExp = new HyperLink();
                            hplnkMedExp.ImageUrl = "~/images/icon/pdf.png";
                            hplnkMedExp.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkMedExp.Target = "_blank";

                            tcMedExpAdult.Controls.Add(hplnkMedExp);
                        }
                        else
                        {
                            float _fMedExpAdult = 0;
                            if (dtFiltered.Rows[iRows]["MedExp_LessYr70"].ToString() != "")
                            {
                                _fMedExpAdult = Convert.ToSingle(dtFiltered.Rows[iRows]["MedExp_LessYr70"].ToString());
                            }

                            if (_fMedExpAdult > 0.0f)
                            {
                                string _MedExpAdult = String.Format("${0:0,0}", _fMedExpAdult);

                                if (_providercompanyid == "38")
                                {
                                    tcMedExpAdult.InnerHtml = _MedExpAdult + "<br/>TCM: $300";
                                }
                                else if (_providercompanyid == "36")
                                {
                                    tcMedExpAdult.InnerHtml = _MedExpAdult + "<br/>TCM: $750";
                                }
                                else
                                {
                                    tcMedExpAdult.InnerHtml = _MedExpAdult;
                                }

                            }
                            else
                            {
                                Image imgMedExpAdult = new Image();
                                imgMedExpAdult.ImageUrl = "~/images/icon/X.png";
                                tcMedExpAdult.Controls.Add(imgMedExpAdult);
                            }
                        }

                        trMedExpadult.Controls.Add(tcMedExpAdult);

                        //Medical Expense >70
                        HtmlTableCell tcMedExp70 = new HtmlTableCell();
                        tcMedExp70.Attributes.Add("class", "bg_grey_2 pad4px");


                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkMedExp70 = new HyperLink();
                            hplnkMedExp70.ImageUrl = "~/images/icon/pdf.png";
                            hplnkMedExp70.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkMedExp70.Target = "_blank";

                            tcMedExp70.Controls.Add(hplnkMedExp70);
                        }
                        else
                        {
                            float _fMedExp70 = 0;

                            if (dtFiltered.Rows[iRows]["MedExp_AboveYr70"].ToString() != "")
                            {
                                _fMedExp70 = Convert.ToSingle(dtFiltered.Rows[iRows]["MedExp_AboveYr70"].ToString());
                            }

                            if (_fMedExp70 > 0.0f)
                            {
                                string _MedExp70 = String.Format("${0:0,0}", _fMedExp70);

                                if (_providercompanyid == "38")
                                {
                                    tcMedExp70.InnerHtml = _MedExp70 + "<br/>TCM: $300";
                                }
                                else if (_providercompanyid == "36")
                                {
                                    tcMedExp70.InnerHtml = _MedExp70 + "<br/>TCM: $750";
                                }
                                else
                                {
                                    tcMedExp70.InnerHtml = _MedExp70;
                                }

                            }
                            else
                            {
                                Image imgMedExp70 = new Image();
                                imgMedExp70.ImageUrl = "~/images/icon/X.png";
                                tcMedExp70.Controls.Add(imgMedExp70);
                            }
                        }

                        trMedExp70.Controls.Add(tcMedExp70);

                        //Emergency Medical Evacuation
                        HtmlTableCell tcEmergencyMedEvac = new HtmlTableCell();
                        tcEmergencyMedEvac.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkEME = new HyperLink();
                            hplnkEME.ImageUrl = "~/images/icon/pdf.png";
                            hplnkEME.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkEME.Target = "_blank";

                            tcEmergencyMedEvac.Controls.Add(hplnkEME);
                        }
                        else if (_providercompanyid == "23")
                        {
                            tcEmergencyMedEvac.InnerHtml = "<font color=Red>*as charged</font>";
                        }
                        else if (_providercompanyid == "24" || _providercompanyid == "29")
                        {
                            tcEmergencyMedEvac.InnerHtml = "<font color=Red>Unlimited</font>";
                        }
                        else
                        {
                            float _fEmMedEval = 0;
                            if (dtFiltered.Rows[iRows]["EmMedEval"].ToString() != "")
                            {
                                _fEmMedEval = Convert.ToSingle(dtFiltered.Rows[iRows]["EmMedEval"].ToString());
                            }

                            if (_fEmMedEval > 0.0f)
                            {
                                string _EmMedEval = String.Format("{0:c0}", _fEmMedEval);

                                if (_providercompanyid == "38")
                                {
                                    tcEmergencyMedEvac.InnerHtml = _EmMedEval + "<br/>(combined cover with Repatriation & Funeral Expense)";
                                }
                                else
                                {
                                    tcEmergencyMedEvac.InnerHtml = _EmMedEval;
                                }

                            }
                            else
                            {
                                Image imgEmMedEval = new Image();
                                imgEmMedEval.ImageUrl = "~/images/icon/X.png";
                                tcEmergencyMedEvac.Controls.Add(imgEmMedEval);
                            }
                        }

                        trEmergencyMedEvac.Controls.Add(tcEmergencyMedEvac);

                        //Repatriation & Funeral Expenses
                        HtmlTableCell tcRepatriation = new HtmlTableCell();
                        tcRepatriation.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkRepat = new HyperLink();
                            hplnkRepat.ImageUrl = "~/images/icon/pdf.png";
                            hplnkRepat.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkRepat.Target = "_blank";

                            tcRepatriation.Controls.Add(hplnkRepat);
                        }
                        else
                        {
                            float _fRepat = 0;
                            if (dtFiltered.Rows[iRows]["BCR"].ToString() != "")
                            {
                                _fRepat = Convert.ToSingle(dtFiltered.Rows[iRows]["BCR"].ToString());
                            }

                            if (dtFiltered.Rows[iRows]["info5"].ToString() == "True")
                            {
                                tcRepatriation.InnerHtml = "<font color=Red>*as charged</font>";

                                if (_providercompanyid == "36" || _providercompanyid == "24" || _providercompanyid == "29")
                                {
                                    tcRepatriation.InnerHtml = "<font color=Red>Unlimited</font>";
                                }

                                if (_providercompanyid == "23")
                                {
                                    tcRepatriation.InnerHtml += "<br/>($30,000 for repatriation)";
                                }

                            }
                            else
                            {
                                if (_fRepat > 0.0f)
                                {
                                    string _Repat = String.Format("{0:c0}", _fRepat);

                                    if (_providercompanyid == "38")
                                    {
                                        tcRepatriation.InnerHtml = _Repat + "<br/>(combined cover with Emergency Medical Evacuation)";
                                    }
                                    else
                                    {
                                        tcRepatriation.InnerHtml = _Repat;
                                    }


                                }
                                else
                                {
                                    Image imgRepat = new Image();
                                    imgRepat.ImageUrl = "~/images/icon/X.png";
                                    tcRepatriation.Controls.Add(imgRepat);
                                }
                            }
                        }

                        trRepatriation.Controls.Add(tcRepatriation);

                        //Hospital Income
                        HtmlTableCell tcHospIncome = new HtmlTableCell();
                        tcHospIncome.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkHI = new HyperLink();
                            hplnkHI.ImageUrl = "~/images/icon/pdf.png";
                            hplnkHI.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkHI.Target = "_blank";

                            tcHospIncome.Controls.Add(hplnkHI);
                        }
                        else if (_providercompanyid == "24") //RSA
                        {
                            tcHospIncome.InnerHtml = String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["NInfo4"].ToString()));
                        }
                        else
                        {
                            float _fHospIncome = 0;
                            if (dtFiltered.Rows[iRows]["HospIncome"].ToString() != "")
                            {
                                _fHospIncome = Convert.ToSingle(dtFiltered.Rows[iRows]["HospIncome"].ToString());
                            }

                            if (_fHospIncome > 0.0f)
                            {
                                string _HospIncome = String.Format("{0:c0}", _fHospIncome);

                                tcHospIncome.InnerHtml = _HospIncome + "/day <br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["NInfo4"].ToString()));

                            }
                            else
                            {
                                Image imgHospIncome = new Image();
                                imgHospIncome.ImageUrl = "~/images/icon/X.png";
                                tcHospIncome.Controls.Add(imgHospIncome);
                            }
                        }

                        trHospIncome.Controls.Add(tcHospIncome);

                        //Pregnancy
                        HtmlTableCell tcPregnancy = new HtmlTableCell();
                        tcPregnancy.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkPregnancy = new HyperLink();
                            hplnkPregnancy.ImageUrl = "~/images/icon/pdf.png";
                            hplnkPregnancy.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkPregnancy.Target = "_blank";

                            tcPregnancy.Controls.Add(hplnkPregnancy);
                        }
                        else
                        {
                            float _fPregnancy = 0;
                            if (dtFiltered.Rows[iRows]["NInfo3"].ToString() != "")
                            {
                                _fPregnancy = Convert.ToSingle(dtFiltered.Rows[iRows]["NInfo3"].ToString());
                            }

                            if (_fPregnancy > 0.0f)
                            {
                                string _Pregnancy = String.Format("{0:c0}", _fPregnancy);

                                if (_providercompanyid == "38")
                                {
                                    tcPregnancy.InnerHtml = "Covered under Medical Expenses (adult)";
                                }
                                else
                                {
                                    tcPregnancy.InnerHtml = _Pregnancy;
                                }

                            }
                            else
                            {
                                Image imgPregnancy = new Image();
                                imgPregnancy.ImageUrl = "~/images/icon/X.png";
                                tcPregnancy.Controls.Add(imgPregnancy);
                            }
                        }

                        trPregnancy.Controls.Add(tcPregnancy);

                        //Overseas Compa Visit
                        HtmlTableCell tcCompaVisit = new HtmlTableCell();
                        tcCompaVisit.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkOCV = new HyperLink();
                            hplnkOCV.ImageUrl = "~/images/icon/pdf.png";
                            hplnkOCV.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkOCV.Target = "_blank";

                            tcCompaVisit.Controls.Add(hplnkOCV);
                        }
                        else
                        {
                            float _fCompaVisit = 0;
                            if (dtFiltered.Rows[iRows]["CompassVisit"].ToString() != "")
                            {
                                _fCompaVisit = Convert.ToSingle(dtFiltered.Rows[iRows]["CompassVisit"].ToString());
                            }

                            if (_fCompaVisit > 0.0f)
                            {
                                string _CompaVisit = String.Format("{0:c0}", _fCompaVisit);
                                tcCompaVisit.InnerHtml = _CompaVisit;

                            }
                            else
                            {
                                Image imgCompaVisit = new Image();
                                imgCompaVisit.ImageUrl = "~/images/icon/X.png";
                                tcCompaVisit.Controls.Add(imgCompaVisit);
                            }
                        }

                        trComVisit.Controls.Add(tcCompaVisit);

                        //Child Guard
                        HtmlTableCell tcChildGuard = new HtmlTableCell();
                        tcChildGuard.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkCG = new HyperLink();
                            hplnkCG.ImageUrl = "~/images/icon/pdf.png";
                            hplnkCG.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkCG.Target = "_blank";

                            tcChildGuard.Controls.Add(hplnkCG);
                        }
                        else
                        {
                            float _fChildGuard = 0;
                            if (dtFiltered.Rows[iRows]["ChildCare"].ToString() != "")
                            {
                                _fChildGuard = Convert.ToSingle(dtFiltered.Rows[iRows]["ChildCare"].ToString());
                            }

                            if (_fChildGuard > 0.0f)
                            {
                                string _ChildGuard = String.Format("{0:c0}", _fChildGuard);
                                tcChildGuard.InnerHtml = _ChildGuard;

                            }
                            else
                            {
                                Image imgChildG = new Image();
                                imgChildG.ImageUrl = "~/images/icon/X.png";
                                tcChildGuard.Controls.Add(imgChildG);
                            }
                        }

                        trChildGuard.Controls.Add(tcChildGuard);

                        //Personal Liability
                        HtmlTableCell tcPL = new HtmlTableCell();
                        tcPL.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkPL = new HyperLink();
                            hplnkPL.ImageUrl = "~/images/icon/pdf.png";
                            hplnkPL.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkPL.Target = "_blank";

                            tcPL.Controls.Add(hplnkPL);
                        }
                        else
                        {
                            float _fPL = 0;
                            if (dtFiltered.Rows[iRows]["PersonalLiability"].ToString() != "")
                            {
                                _fPL = Convert.ToSingle(dtFiltered.Rows[iRows]["PersonalLiability"].ToString());
                            }

                            if (_fPL > 0.0f)
                            {
                                string _PL = String.Format("{0:c0}", _fPL);
                                tcPL.InnerHtml = _PL;
                            }
                            else
                            {
                                Image imgPL = new Image();
                                imgPL.ImageUrl = "~/images/icon/X.png";
                                tcPL.Controls.Add(imgPL);
                            }
                        }

                        trPersonalLiability.Controls.Add(tcPL);

                        //Loss Baggage & Personal Effects
                        HtmlTableCell tcLossBaggage = new HtmlTableCell();
                        tcLossBaggage.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkLossBag = new HyperLink();
                            hplnkLossBag.ImageUrl = "~/images/icon/pdf.png";
                            hplnkLossBag.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkLossBag.Target = "_blank";

                            tcLossBaggage.Controls.Add(hplnkLossBag);
                        }
                        else
                        {
                            float _fLossBaggage = 0;
                            if (dtFiltered.Rows[iRows]["BagPerEffect"].ToString() != "")
                            {
                                _fLossBaggage = Convert.ToSingle(dtFiltered.Rows[iRows]["BagPerEffect"].ToString());
                            }

                            if (_fLossBaggage > 0.0f)
                            {
                                string _LossBaggage = String.Format("{0:c0}", _fLossBaggage);
                                tcLossBaggage.InnerHtml = _LossBaggage;

                                if (_providercompanyid == "38")
                                {
                                    tcLossBaggage.InnerHtml = _LossBaggage + "<br/>($500 per article/laptop/mobile phone or PDA)";
                                }

                                if (_providercompanyid == "24")
                                {
                                    tcLossBaggage.InnerHtml = _LossBaggage + "<br/>$1,000 per item";
                                }
                            }
                            else
                            {
                                Image imgLossBaggage = new Image();
                                imgLossBaggage.ImageUrl = "~/images/icon/X.png";
                                tcLossBaggage.Controls.Add(imgLossBaggage);
                            }
                        }

                        trLossBaggage.Controls.Add(tcLossBaggage);

                        //trOverseasBaggage
                        HtmlTableCell tcOverseasBaggage = new HtmlTableCell();
                        tcOverseasBaggage.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkOBag = new HyperLink();
                            hplnkOBag.ImageUrl = "~/images/icon/pdf.png";
                            hplnkOBag.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkOBag.Target = "_blank";

                            tcOverseasBaggage.Controls.Add(hplnkOBag);
                        }
                        else
                        {
                            float _fOverseasBaggage = 0;
                            if (dtFiltered.Rows[iRows]["BagDelay"].ToString() != "")
                            {
                                _fOverseasBaggage = Convert.ToSingle(dtFiltered.Rows[iRows]["BagDelay"].ToString());
                            }

                            if (_fOverseasBaggage > 0.0f)
                            {
                                string _OverseasBaggage = String.Format("{0:c0}", _fOverseasBaggage) + "/" + dtFiltered.Rows[iRows]["Ninfo5"].ToString() + "-hour delay";
                                _OverseasBaggage += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo6"].ToString()));
                                tcOverseasBaggage.InnerHtml = _OverseasBaggage;

                                if (_providercompanyid == "38")
                                {
                                    tcOverseasBaggage.InnerHtml = String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo6"].ToString()));
                                }
                            }
                            else
                            {
                                Image imgOverseasBaggage = new Image();
                                imgOverseasBaggage.ImageUrl = "~/images/icon/X.png";
                                tcOverseasBaggage.Controls.Add(imgOverseasBaggage);
                            }
                        }

                        trOverseasBaggage.Controls.Add(tcOverseasBaggage);

                        //Trip Cancellation
                        HtmlTableCell tcTripCancellation = new HtmlTableCell();
                        tcTripCancellation.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTripCancel = new HyperLink();
                            hplnkTripCancel.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTripCancel.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTripCancel.Target = "_blank";

                            tcTripCancellation.Controls.Add(hplnkTripCancel);
                        }
                        else
                        {
                            float _fTripCancellation = 0;
                            if (dtFiltered.Rows[iRows]["DepositTripCancel"].ToString() != "")
                            {
                                _fTripCancellation = Convert.ToSingle(dtFiltered.Rows[iRows]["DepositTripCancel"].ToString());
                            }

                            if (_fTripCancellation > 0.0f)
                            {
                                string _TripCancellation = String.Format("{0:c0}", _fTripCancellation);
                                tcTripCancellation.InnerHtml = _TripCancellation;

                            }
                            else
                            {
                                Image imgTripCancellation = new Image();
                                imgTripCancellation.ImageUrl = "~/images/icon/X.png";
                                tcTripCancellation.Controls.Add(imgTripCancellation);
                            }
                        }

                        trTripCancellation.Controls.Add(tcTripCancellation);

                        //Trip Curtailment
                        HtmlTableCell tcTripCurtailment = new HtmlTableCell();
                        tcTripCurtailment.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTripCurtail = new HyperLink();
                            hplnkTripCurtail.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTripCurtail.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTripCurtail.Target = "_blank";

                            tcTripCurtailment.Controls.Add(hplnkTripCurtail);
                        }
                        else
                        {
                            float _fTripCurtailment = 0;
                            if (dtFiltered.Rows[iRows]["Curtailment"].ToString() != "")
                            {
                                _fTripCurtailment = Convert.ToSingle(dtFiltered.Rows[iRows]["Curtailment"].ToString());
                            }

                            if (_fTripCurtailment > 0.0f)
                            {
                                string _TripCurtailment = String.Format("{0:c0}", _fTripCurtailment);
                                tcTripCurtailment.InnerHtml = _TripCurtailment;

                                if (_providercompanyid == "38")
                                {
                                    tcTripCurtailment.InnerHtml = String.Format("{0:c0}", Convert.ToSingle(dtFiltered.Rows[iRows]["DepositTripCancel"].ToString()));
                                }

                            }
                            else
                            {
                                Image imgTripCurtailment = new Image();
                                imgTripCurtailment.ImageUrl = "~/images/icon/X.png";
                                tcTripCurtailment.Controls.Add(imgTripCurtailment);
                            }
                        }

                        trTripCurtailment.Controls.Add(tcTripCurtailment);

                        //Overseas Travel Delay
                        HtmlTableCell tcTravelDelay = new HtmlTableCell();
                        tcTravelDelay.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTravelDelay = new HyperLink();
                            hplnkTravelDelay.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTravelDelay.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTravelDelay.Target = "_blank";

                            tcTravelDelay.Controls.Add(hplnkTravelDelay);
                        }
                        else
                        {
                            float _fTravelDelay = 0;
                            if (dtFiltered.Rows[iRows]["TravelDelay"].ToString() != "")
                            {
                                _fTravelDelay = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelDelay"].ToString());
                            }

                            if (_fTravelDelay > 0.0f)
                            {

                                if (_providercompanyid == "38")
                                {
                                    string _TravelDelay = "$1,000 <br/>($100 per 6 hrs *)<br/>* $50 per 6 hrs for Jetstar and Tiger";
                                    tcTravelDelay.InnerHtml = _TravelDelay;

                                }
                                else
                                {
                                    string _TravelDelay = String.Format("{0:c0}", _fTravelDelay) + "/" + dtFiltered.Rows[iRows]["Ninfo7"].ToString() + "-hour delay";
                                    _TravelDelay += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo8"].ToString()));
                                    tcTravelDelay.InnerHtml = _TravelDelay;
                                }

                            }
                            else
                            {
                                Image imgTravelDelay = new Image();
                                imgTravelDelay.ImageUrl = "~/images/icon/X.png";
                                tcTravelDelay.Controls.Add(imgTravelDelay);
                            }
                        }

                        trTravelDelay.Controls.Add(tcTravelDelay);

                        //Missed Travel Connection
                        HtmlTableCell tcTravelConnection = new HtmlTableCell();
                        tcTravelConnection.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTravelCon = new HyperLink();
                            hplnkTravelCon.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTravelCon.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTravelCon.Target = "_blank";

                            tcTravelConnection.Controls.Add(hplnkTravelCon);
                        }
                        else
                        {
                            float _fTravelConnection = 0;
                            if (dtFiltered.Rows[iRows]["MissTravelConnection"].ToString() != "")
                            {
                                _fTravelConnection = Convert.ToSingle(dtFiltered.Rows[iRows]["MissTravelConnection"].ToString());
                            }

                            if (_fTravelConnection > 0.0f)
                            {
                                string _TravelConnection = String.Format("{0:c0}", _fTravelConnection);
                                tcTravelConnection.InnerHtml = _TravelConnection;

                            }
                            else
                            {
                                Image imgTravelConnection = new Image();
                                imgTravelConnection.ImageUrl = "~/images/icon/X.png";
                                tcTravelConnection.Controls.Add(imgTravelConnection);
                            }
                        }

                        trTravelConnection.Controls.Add(tcTravelConnection);

                        //Travel Overbooked
                        HtmlTableCell tcTravelOverbooked = new HtmlTableCell();
                        tcTravelOverbooked.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTravelOver = new HyperLink();
                            hplnkTravelOver.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTravelOver.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTravelOver.Target = "_blank";

                            tcTravelOverbooked.Controls.Add(hplnkTravelOver);
                        }
                        else
                        {
                            float _fTravelOverbooked = 0;
                            if (dtFiltered.Rows[iRows]["TravelOverBook"].ToString() != "")
                            {
                                _fTravelOverbooked = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelOverBook"].ToString());
                            }

                            if (_fTravelOverbooked > 0.0f)
                            {
                                string _TravelOverbooked = String.Format("{0:c0}", _fTravelOverbooked);
                                tcTravelOverbooked.InnerHtml = _TravelOverbooked;

                            }
                            else
                            {
                                Image imgTravelOverbooked = new Image();
                                imgTravelOverbooked.ImageUrl = "~/images/icon/X.png";
                                tcTravelOverbooked.Controls.Add(imgTravelOverbooked);
                            }
                        }

                        trTravelOverbooked.Controls.Add(tcTravelOverbooked);

                        //Loss of Personal Money
                        HtmlTableCell tcLossMoney = new HtmlTableCell();
                        tcLossMoney.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkLossMoney = new HyperLink();
                            hplnkLossMoney.ImageUrl = "~/images/icon/pdf.png";
                            hplnkLossMoney.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkLossMoney.Target = "_blank";

                            tcLossMoney.Controls.Add(hplnkLossMoney);
                        }
                        else
                        {
                            float _fLossMoney = 0;
                            if (dtFiltered.Rows[iRows]["PersonalMoney"].ToString() != "")
                            {
                                _fLossMoney = Convert.ToSingle(dtFiltered.Rows[iRows]["PersonalMoney"].ToString());
                            }

                            if (_fLossMoney > 0.0f)
                            {
                                string _LossMoney = String.Format("{0:c0}", _fLossMoney);
                                tcLossMoney.InnerHtml = _LossMoney;

                            }
                            else
                            {
                                Image imgLossMoney = new Image();
                                imgLossMoney.ImageUrl = "~/images/icon/X.png";
                                tcLossMoney.Controls.Add(imgLossMoney);
                            }
                        }

                        trLossMoney.Controls.Add(tcLossMoney);

                        //Loss of Travel Documents
                        HtmlTableCell tcLossDocument = new HtmlTableCell();
                        tcLossDocument.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkLossDoc = new HyperLink();
                            hplnkLossDoc.ImageUrl = "~/images/icon/pdf.png";
                            hplnkLossDoc.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkLossDoc.Target = "_blank";

                            tcLossDocument.Controls.Add(hplnkLossDoc);
                        }
                        else
                        {
                            float _fLossDocument = 0;
                            if (dtFiltered.Rows[iRows]["TravelDoc"].ToString() != "")
                            {
                                _fLossDocument = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelDoc"].ToString());
                            }

                            if (_fLossDocument > 0.0f)
                            {
                                string _LossDocument = String.Format("{0:c0}", _fLossDocument);
                                tcLossDocument.InnerHtml = _LossDocument;

                            }
                            else
                            {
                                Image imgLossDocs = new Image();
                                imgLossDocs.ImageUrl = "~/images/icon/X.png";
                                tcLossDocument.Controls.Add(imgLossDocs);
                            }
                        }

                        trLossDocument.Controls.Add(tcLossDocument);

                        //Closure of Travel Agency
                        HtmlTableCell tcClosureAgency = new HtmlTableCell();
                        tcClosureAgency.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkClosure = new HyperLink();
                            hplnkClosure.ImageUrl = "~/images/icon/pdf.png";
                            hplnkClosure.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkClosure.Target = "_blank";

                            tcClosureAgency.Controls.Add(hplnkClosure);
                        }
                        else
                        {
                            float _fClosure = 0;
                            if (dtFiltered.Rows[iRows]["Info3"].ToString() != "")
                            {
                                _fClosure = Convert.ToSingle(dtFiltered.Rows[iRows]["Info3"].ToString());
                            }

                            if (_fClosure > 0.0f)
                            {
                                string _Closure = String.Format("{0:c0}", _fClosure);
                                tcClosureAgency.InnerHtml = _Closure;

                            }
                            else
                            {
                                Image imgClosure = new Image();
                                imgClosure.ImageUrl = "~/images/icon/X.png";
                                tcClosureAgency.Controls.Add(imgClosure);
                            }
                        }

                        trClosureAgency.Controls.Add(tcClosureAgency);

                        //Home Contents
                        HtmlTableCell tcHomeContent = new HtmlTableCell();
                        tcHomeContent.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkHome = new HyperLink();
                            hplnkHome.ImageUrl = "~/images/icon/pdf.png";
                            hplnkHome.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkHome.Target = "_blank";

                            tcHomeContent.Controls.Add(hplnkHome);
                        }
                        else
                        {
                            float _fHomeContent = 0;
                            if (dtFiltered.Rows[iRows]["FBHCP"].ToString() != "")
                            {
                                _fHomeContent = Convert.ToSingle(dtFiltered.Rows[iRows]["FBHCP"].ToString());
                            }

                            if (_fHomeContent > 0.0f)
                            {
                                string _HomeContent = String.Format("{0:c0}", _fHomeContent);
                                tcHomeContent.InnerHtml = _HomeContent;

                                if (_providercompanyid == "23")
                                {
                                    if (Session["TripType"].ToString() == "A")
                                    {
                                        tcHomeContent.InnerHtml = "Optional";
                                    }
                                }
                            }
                            else
                            {
                                Image imgHomeContent = new Image();
                                imgHomeContent.ImageUrl = "~/images/icon/X.png";
                                tcHomeContent.Controls.Add(imgHomeContent);
                            }
                        }

                        trHomeContent.Controls.Add(tcHomeContent);

                        //Rental Vehicle
                        HtmlTableCell tcRentalVehicle = new HtmlTableCell();
                        tcRentalVehicle.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkRV = new HyperLink();
                            hplnkRV.ImageUrl = "~/images/icon/pdf.png";
                            hplnkRV.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkRV.Target = "_blank";

                            tcRentalVehicle.Controls.Add(hplnkRV);
                        }
                        else
                        {
                            float _fRentalVehicle = 0;
                            if (dtFiltered.Rows[iRows]["ACRR"].ToString() != "")
                            {
                                _fRentalVehicle = Convert.ToSingle(dtFiltered.Rows[iRows]["ACRR"].ToString());
                            }

                            if (_fRentalVehicle > 0.0f)
                            {
                                string _RentalVehicle = String.Format("{0:c0}", _fRentalVehicle);
                                tcRentalVehicle.InnerHtml = _RentalVehicle;

                            }
                            else
                            {
                                Image imgRentalVehicle = new Image();
                                imgRentalVehicle.ImageUrl = "~/images/icon/X.png";
                                tcRentalVehicle.Controls.Add(imgRentalVehicle);
                            }
                        }

                        trRentalVehicle.Controls.Add(tcRentalVehicle);

                        //Hijack
                        HtmlTableCell tcHijack = new HtmlTableCell();
                        tcHijack.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkHJ = new HyperLink();
                            hplnkHJ.ImageUrl = "~/images/icon/pdf.png";
                            hplnkHJ.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkHJ.Target = "_blank";

                            tcHijack.Controls.Add(hplnkHJ);
                        }
                        else
                        {
                            float _fHijack = 0;
                            if (dtFiltered.Rows[iRows]["Terrorism"].ToString() != "")
                            {
                                _fHijack = Convert.ToSingle(dtFiltered.Rows[iRows]["Terrorism"].ToString());
                            }

                            if (_fHijack > 0.0f)
                            {
                                string _Hijack = String.Format("{0:c0}", _fHijack) + "/" + dtFiltered.Rows[iRows]["Info1"].ToString() + "-hour";
                                _Hijack += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Info2"].ToString()));
                                tcHijack.InnerHtml = _Hijack;

                            }
                            else
                            {
                                Image imgHijack = new Image();
                                imgHijack.ImageUrl = "~/images/icon/X.png";
                                tcHijack.Controls.Add(imgHijack);
                            }
                        }

                        trHijack.Controls.Add(tcHijack);

                        //Kidnap / Hostage
                        HtmlTableCell tcKidnap = new HtmlTableCell();
                        tcKidnap.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkKidnap = new HyperLink();
                            hplnkKidnap.ImageUrl = "~/images/icon/pdf.png";
                            hplnkKidnap.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkKidnap.Target = "_blank";

                            tcKidnap.Controls.Add(hplnkKidnap);
                        }
                        else
                        {
                            float _fKidnap = 0;
                            if (dtFiltered.Rows[iRows]["KidnapHostage"].ToString() != "")
                            {
                                _fKidnap = Convert.ToSingle(dtFiltered.Rows[iRows]["KidnapHostage"].ToString());
                            }

                            if (_fKidnap > 0.0f)
                            {
                                string _Kidnap = String.Format("{0:c0}", _fKidnap);
                                tcKidnap.InnerHtml = _Kidnap;

                            }
                            else
                            {
                                Image imgKidnap = new Image();
                                imgKidnap.ImageUrl = "~/images/icon/X.png";
                                tcKidnap.Controls.Add(imgKidnap);
                            }
                        }

                        trKidnap.Controls.Add(tcKidnap);

                        //Emergency Tel Charges
                        HtmlTableCell tcTelCharge = new HtmlTableCell();
                        tcTelCharge.Attributes.Add("class", "bg_grey_2 pad4px");

                        if (_providercompanyid == "34")
                        {
                            HyperLink hplnkTelCharge = new HyperLink();
                            hplnkTelCharge.ImageUrl = "~/images/icon/pdf.png";
                            hplnkTelCharge.NavigateUrl = "~/policy_docs/ChinaTaiping/Coverage.pdf";
                            hplnkTelCharge.Target = "_blank";

                            tcTelCharge.Controls.Add(hplnkTelCharge);
                        }
                        else
                        {
                            float _fTelCharge = 0;
                            if (dtFiltered.Rows[iRows]["EmTelCharge"].ToString() != "")
                            {
                                _fTelCharge = Convert.ToSingle(dtFiltered.Rows[iRows]["EmTelCharge"].ToString());
                            }

                            if (dtFiltered.Rows[iRows]["Info6"].ToString() != "" && dtFiltered.Rows[iRows]["Info6"].ToString() == "True")
                            {
                                tcTelCharge.InnerHtml = "<font color='red'>*actual cost</font>";
                            }
                            else
                            {

                                if (_fTelCharge > 0.0f)
                                {
                                    string _TelCharge = String.Format("{0:c0}", _fTelCharge);
                                    tcTelCharge.InnerHtml = _TelCharge;

                                }
                                else
                                {
                                    Image imgTelCharge = new Image();
                                    imgTelCharge.ImageUrl = "~/images/icon/X.png";
                                    tcTelCharge.Controls.Add(imgTelCharge);
                                }
                            }
                        }

                        trTelCharge.Controls.Add(tcTelCharge);

                        // policy
                        HtmlTableCell tcPolicyPDF = new HtmlTableCell();
                        tcPolicyPDF.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad4px");

                        string _policyId = dtFiltered.Rows[iRows]["NInfo1"].ToString();

                        ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
                        ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

                        _policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

                        string docurl = _policydoc.UploadPath;
                        HyperLink _lnkTest = new HyperLink();
                        _lnkTest.NavigateUrl = docurl;

                        HyperLink hplnkPolicyDoc = new HyperLink();
                        hplnkPolicyDoc.ImageUrl = "~/images/icon/pdf.png";
                        hplnkPolicyDoc.NavigateUrl = _lnkTest.ResolveClientUrl(docurl);
                        hplnkPolicyDoc.Target = "_blank";

                        tcPolicyPDF.Controls.Add(hplnkPolicyDoc);
                        trPolicy.Controls.Add(tcPolicyPDF);

                        //bottom
                        HtmlTableCell tcBottomNew = new HtmlTableCell();
                        tcBottomNew.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divBottomNew = new HtmlGenericControl("div");

                        HtmlGenericControl divBottomNew1 = new HtmlGenericControl("div");
                        divBottomNew1.Attributes.Add("class", "curvebottomleft left");

                        HtmlGenericControl divBottomNew2 = new HtmlGenericControl("div");
                        divBottomNew2.Attributes.Add("class", "curvebottomright right");

                        divBottomNew.Controls.Add(divBottomNew1);
                        divBottomNew.Controls.Add(divBottomNew2);

                        tcBottomNew.Controls.Add(divBottomNew);

                        trBottom.Controls.Add(tcBottomNew);

                        //Interested Bar

                        //if (rowCount == 2)
                        //{
                        //    divBar.Style.Add("width", "567px");
                        //    divCenterBar.Style.Add("width", "548px");
                        //    tdBarLeft.Width = "420px";
                        //}
                        //else if (rowCount == 3)
                        //{
                        //    divBar.Style.Add("width", "663px");
                        //    divCenterBar.Style.Add("width", "648px");
                        //    //tdBarLeft.Style.Add("class", "w322px");
                        //    tdBarLeft.Width = "325px";
                        //}
                        //else if (rowCount == 4)
                        //{
                        //    divBar.Style.Add("width", "750px");
                        //    divCenterBar.Style.Add("width", "710px");
                        //    tdBarLeft.Width = "235px";
                        //}

                        if (rowCount == 1)
                        {
                            divBar.Style.Add("width", "500px");
                            divCenterBar.Style.Add("width", "458px");
                            tdBarLeft.Width = "500px";
                        }
                        else if (rowCount == 2)
                        {
                            divBar.Style.Add("width", "637px");
                            divCenterBar.Style.Add("width", "598px");
                            tdBarLeft.Width = "350px";
                        }
                        else if (rowCount == 3)
                        {
                            divBar.Style.Add("width", "745px");
                            divCenterBar.Style.Add("width", "678px");
                            tdBarLeft.Width = "255px";
                        }
                        else if (rowCount == 4)
                        {
                            divBar.Style.Add("width", "795px");
                            divCenterBar.Style.Add("width", "710px");
                            tdBarLeft.Width = "210px";
                        }
                        else if (rowCount == 5)
                        {
                            divBar.Style.Add("width", "800px");
                            divCenterBar.Style.Add("width", "780px");
                            tdBarLeft.Width = "205px";
                        }
                        else if (rowCount == 6)
                        {
                            divBar.Style.Add("width", "100%");
                            divCenterBar.Style.Add("width", "820px");
                            tdBarLeft.Width = "165px";
                        }
                        else if (rowCount == 7)
                        {
                            divBar.Style.Add("width", "100%");
                            divCenterBar.Style.Add("width", "820px");
                            tdBarLeft.Width = "165px";
                        }


                        //BAR/ARROWS
                        HtmlTableCell tcArrows = new HtmlTableCell();
                        tcArrows.Attributes.Add("class", "txtcenter w110px");
                        tcArrows.Attributes.Add("valign", "center");
                        Image imgArrows = new Image();
                        imgArrows.ImageUrl = "../images/form/icon_arrow_down.png";
                        imgArrows.Width = 30;
                        imgArrows.Height = 20;

                        if (rowCount == 1)
                        {
                            tdArrowLeftAlign.Width = "110px";
                        }
                        else if (rowCount == 2)
                        {
                            tdArrowLeftAlign.Width = "110px";
                        }
                        else if (rowCount == 3)
                        {
                            tdArrowLeftAlign.Width = "110px";
                        }
                        else if (rowCount == 4)
                        {
                            tdArrowLeftAlign.Width = "115px";
                        }
                        else if (rowCount == 5)
                        {
                            tdArrowLeftAlign.Width = "140px";
                        }
                        else if (rowCount == 6)
                        {
                            tdArrowLeftAlign.Width = "135px";
                        }
                        else if (rowCount == 7)
                        {
                            tdArrowLeftAlign.Width = "150px";
                        }
                        //tcArrows.Width = iTopWidth.ToString() + "%";
                        tcArrows.Controls.Add(imgArrows);
                        trArrows.Controls.Add(tcArrows);

                        //OPTIONS

                        //top
                        if (rowCount == 2)
                        {
                            tdTopPad.Attributes.Add("class", "w312px");
                        }
                        else if (rowCount == 3)
                        {
                            tdTopPad.Attributes.Add("class", "w400px");
                        }
                        else if (rowCount == 4)
                        {
                            tdTopPad.Attributes.Add("class", "w480px");
                        }
                        else if (rowCount == 5)
                        {
                            tdTopPad.Attributes.Add("class", "w540px");
                        }
                        else if (rowCount == 6)
                        {
                            tdTopPad.Attributes.Add("class", "w600px");
                        }


                        HtmlTableCell tcTopOptions = new HtmlTableCell();
                        tcTopOptions.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divTopOption = new HtmlGenericControl("div");

                        HtmlGenericControl divTopOption1 = new HtmlGenericControl("div");
                        divTopOption1.Attributes.Add("class", "curvetopleft left");

                        HtmlGenericControl divTopOption2 = new HtmlGenericControl("div");
                        divTopOption2.Attributes.Add("class", "curvetopright right");

                        divTopOption.Controls.Add(divTopOption1);
                        divTopOption.Controls.Add(divTopOption2);

                        tcTopOptions.Controls.Add(divTopOption);

                        trTopOptions.Controls.Add(tcTopOptions);

                        //top
                        if (rowCount == 2)
                        {
                            tdTopPad.Attributes.Add("class", "w312px");
                        }
                        else if (rowCount == 3)
                        {
                            tdTopPad.Attributes.Add("class", "w400px");
                        }
                        else if (rowCount == 4)
                        {
                            tdTopPad.Attributes.Add("class", "w480px");
                        }
                        else if (rowCount == 5)
                        {
                            tdTopPad.Attributes.Add("class", "w540px");
                        }
                        else if (rowCount == 6)
                        {
                            tdTopPad.Attributes.Add("class", "w600px");
                        }

                        //toppad on top
                        HtmlTableCell tcTopOptionsTop = new HtmlTableCell();
                        tcTopOptionsTop.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divTopOptionTop = new HtmlGenericControl("div");

                        HtmlGenericControl divTopOption1Top = new HtmlGenericControl("div");
                        divTopOption1Top.Attributes.Add("class", "curvetopleft left");

                        HtmlGenericControl divTopOption2Top = new HtmlGenericControl("div");
                        divTopOption2Top.Attributes.Add("class", "curvetopright right");

                        divTopOptionTop.Controls.Add(divTopOption1Top);
                        divTopOptionTop.Controls.Add(divTopOption2Top);

                        tcTopOptionsTop.Controls.Add(divTopOptionTop);

                        trTopOptionsTop.Controls.Add(tcTopOptionsTop);

                        string _tatempresultid = dtFiltered.Rows[iRows]["TAInsID"].ToString();
                        string _companyName = "";
                        string imageurl = "/images/public/logo/";

                        if (_providercompanyid == "23")
                        {
                            _companyName = "HSBC Insurance";
                            imageurl += "hsbc.png";
                        }
                        else if (_providercompanyid == "24")
                        {
                            _companyName = "RSA Insurance";
                            imageurl += "rsa.png";
                        }
                        else if (_providercompanyid == "29")
                        {
                            _companyName = "Liberty Insurance";
                            imageurl += "liberty.png";
                        }
                        else if (_providercompanyid == "30")
                        {
                            _companyName = "Etiqa Insurance";
                            imageurl += "etiqa.png";
                        }
                        else if (_providercompanyid == "31")
                        {
                            _companyName = "Chartis Insurance";
                            imageurl += "chartis.png";
                        }
                        else if (_providercompanyid == "34")
                        {
                            _companyName = "China Taiping Insurance";
                            imageurl += "chinataiping.png";
                        }
                        else if (_providercompanyid == "35")
                        {
                            _companyName = "EQ Insurance";
                            imageurl += "eq.png";
                        }
                        else if (_providercompanyid == "36")
                        {
                            _companyName = "ACE Insurance";
                            imageurl += "ace.png";
                        }
                        else if (_providercompanyid == "37")
                        {
                            _companyName = "1Cover Insurance";
                            imageurl += "1cover.png";
                        }
                        else if (_providercompanyid == "38")
                        {
                            _companyName = "DirectAsia Insurance";
                            imageurl += "directasia.png";
                        }

                        string _planname = dtFiltered.Rows[iRows]["PlanName"].ToString();
                        string _premium = dtFiltered.Rows[iRows]["AnnualPremium"].ToString();
                        string _taid = Session[General.TAId].ToString();
                        string _coverage = dtFiltered.Rows[iRows]["coveragelevel"].ToString();
                        //buy online me
                        HtmlTableCell tcBuyOnline = new HtmlTableCell();
                        tcBuyOnline.Width = iTopWidth.ToString() + "%";
                        tcBuyOnline.Attributes.Add("class", "bg_grey_2 border2pxdotb pad4pxtb");
                        Button btnBuyOnline = new Button();
                        btnBuyOnline.ID = "btnBuyOnline" + rowCount.ToString() + iRows.ToString() + _coverage;
                        btnBuyOnline.CssClass = "button_buy-now120";
                        btnBuyOnline.CommandArgument = _providercompanyid + "," + _tatempresultid + "," + _planname + "," + _premium;
                        btnBuyOnline.OnClientClick = "javascript:void(0);ShowPopupDetails('" + _providercompanyid + "','" + imageurl + "','" + _tatempresultid + "','" + _premium + "','" + _taid + "', '" + _planname + "', 'BN');return false;";

                        tcBuyOnline.Controls.Add(btnBuyOnline);
                        trBuyOnline.Controls.Add(tcBuyOnline);

                        //buy online top area
                        HtmlTableCell tcBuyOnlineTop = new HtmlTableCell();
                        tcBuyOnlineTop.Width = iTopWidth.ToString() + "%";
                        tcBuyOnlineTop.Attributes.Add("class", "bg_grey_2 border2pxdotb pad4pxtb");
                        Button btnBuyOnlineTop = new Button();
                        btnBuyOnlineTop.ID = "btnBuyOnlineTop" + rowCount.ToString() + iRows.ToString() + _coverage;
                        btnBuyOnlineTop.CssClass = "button_buy-now120";
                        btnBuyOnlineTop.CommandArgument = _providercompanyid + "," + _tatempresultid + "," + _planname + "," + _premium;
                        btnBuyOnlineTop.OnClientClick = "javascript:void(0);ShowPopupDetails('" + _providercompanyid + "','" + imageurl + "','" + _tatempresultid + "','" + _premium + "','" + _taid + "', '" + _planname + "', 'BN');return false;";

                        tcBuyOnlineTop.Controls.Add(btnBuyOnlineTop);
                        trBuyTop.Controls.Add(tcBuyOnlineTop);

                        //email me
                        //HtmlTableCell tcEmailMe = new HtmlTableCell();
                        //tcEmailMe.Attributes.Add("class", "bg_grey_2 border2pxdotb pad4pxtb");

                        //Button btnEmailMe = new Button();
                        //btnEmailMe.CssClass = "button_email-me";
                        //btnEmailMe.OnClientClick = "javascript:void(0);ShowPopupDetails('" + _providercompanyid + "','" + imageurl + "','" + _tatempresultid + "','" + _premium + "','" + _taid + "', '" + _planname + "', 'EM');return false;";

                        //tcEmailMe.Controls.Add(btnEmailMe);
                        //trEmailMe.Controls.Add(tcEmailMe);


                        //email 
                        HtmlTableCell tcEmailThis = new HtmlTableCell();
                        tcEmailThis.Attributes.Add("class", "bg_grey_2 border2pxdotb pad4pxtb");

                        Button btnEmailThis = new Button();
                        btnEmailThis.CssClass = "button_email120";
                        btnEmailThis.ID = "btnEmailThis" + rowCount.ToString() + iRows.ToString();
                        btnEmailThis.CommandArgument = _providercompanyid + "," + _tatempresultid;
                        btnEmailThis.Command += new CommandEventHandler(btnEmailThis_Click);
                        btnEmailThis.OnClientClick = "javascript:void(0);ShowPopupDetails('" + _providercompanyid + "','" + imageurl + "','" + _tatempresultid + "','" + _premium + "','" + _taid + "', '" + _planname + "', 'ET');return false;";

                        tcEmailThis.Controls.Add(btnEmailThis);
                        trEmailThis.Controls.Add(tcEmailThis);


                        //bottom
                        HtmlTableCell tcBottomOptions = new HtmlTableCell();
                        tcBottomOptions.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divBottomOption = new HtmlGenericControl("div");

                        HtmlGenericControl divBottomOption1 = new HtmlGenericControl("div");
                        divBottomOption1.Attributes.Add("class", "curvebottomleft left");

                        HtmlGenericControl divBottomOption2 = new HtmlGenericControl("div");
                        divBottomOption2.Attributes.Add("class", "curvebottomright right");

                        divBottomOption.Controls.Add(divBottomOption1);
                        divBottomOption.Controls.Add(divBottomOption2);

                        tcBottomOptions.Width = iTopWidth.ToString() + "%";
                        tcBottomOptions.Controls.Add(divBottomOption);

                        trBottomOptions.Controls.Add(tcBottomOptions);

                        //bottom on top
                        HtmlTableCell tcBottomOptionsTop = new HtmlTableCell();
                        tcBottomOptionsTop.Attributes.Add("class", "bg_grey_2");

                        HtmlGenericControl divBottomOptionTop = new HtmlGenericControl("div");

                        HtmlGenericControl divBottomOption1Top = new HtmlGenericControl("div");
                        divBottomOption1Top.Attributes.Add("class", "curvebottomleft left");

                        HtmlGenericControl divBottomOption2Top = new HtmlGenericControl("div");
                        divBottomOption2Top.Attributes.Add("class", "curvebottomright right");

                        divBottomOptionTop.Controls.Add(divBottomOption1Top);
                        divBottomOptionTop.Controls.Add(divBottomOption2Top);

                        tcBottomOptionsTop.Width = iTopWidth.ToString() + "%";
                        tcBottomOptionsTop.Controls.Add(divBottomOptionTop);

                        trBottomOptionsTop.Controls.Add(tcBottomOptionsTop);
                    }

                }
            }
            else
            {
                //Response.Redirect("~/travel-insurance/");
                BackToSearchPage();
            }
        }
        else
        {
            //Response.Redirect("~/travel-insurance/");
            BackToSearchPage();
        }

    }

    private string GetCovertype(string covertype)
    {
        string coverparam = "";
        if (covertype == "IND")
            coverparam = "Individual";
        else if (covertype == "INS")
            coverparam = "IndividualSpouse";
        else if (covertype == "FML")
            coverparam = "Family";
        else if (covertype == "INC")
            coverparam = "IndividualChild";

        return coverparam;
    }

    private bool SendMailToUser()
    {
        string userfirstname = txtFullName.Text;

        bool _retVal = false;

        string _emailTo = txtEmail.Text;
        string _customername = userfirstname;
        string _emailSubject = "Your Travel Insurance Quotes on CompareXpress";
        string _mailBody = "";
        string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
        string imgLogoUrl = _currentDomainUrl + CE.Configuration.MyConfigurationManager.GetAppSettingValue("LogoPath");

        _mailBody = "<body class='email_body'>";
        _mailBody += "<style type='text/css'>";
        _mailBody += ".email_body {background:white;margin:0; padding:0; color:#4c4c4c; font-family:Arial, Helvetica, sans-serif; font-size:0.85em;}";
        _mailBody += "a {text-decoration:underline;color:#2c95cc;} ";
        _mailBody += "#email_container {margin:0 auto;padding:20px;width:600px; height:auto;} ";
        _mailBody += "#email_body {width:100%; text-align: left !important;} ";
        _mailBody += ".email_pad10px {padding:10px;} ";
        _mailBody += ".email_results td {width:33%;} ";
        _mailBody += "</style>";
        _mailBody += "<center>";

        _mailBody += "<table cellpadding='0' cellspacing='0' border='0' style='padding:20px;' width='600'>";
        _mailBody += "<tr><td width='360'><a href='http://www.comparexpress.com/car-insurance/login.aspx' target='_blank'><img src='" + _currentDomainUrl + "/images/email/header_quote.png' width='596' height='187' alt='CompareXpress' border='0' /></a></td></tr>";
        //_mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'><strong>Dear " + Session[General.UserName].ToString() + ",</strong><br/><br/>";
        _mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'><strong>Dear " + userfirstname + ",</strong><br/><br/>";
        _mailBody += "Thank you for using CompareXpress Travel Insurance Comparison Engine:<br/><br/>";
        _mailBody += "Please find below a copy of your requested quote.<br/><br/>";

        DataView dvResults = new DataView((DataTable)Cache["TAResultsQuotes" + Session[General.TAId].ToString()]);

        string strTAId = inputResultId.Value;
        dvResults.RowFilter = " TAInsID in (" + strTAId + ")";

        DataTable dtResults = dvResults.ToTable();


        _mailBody += "Destination: " + lblDestination.Text + "<br/>";
        _mailBody += "Travel Date: " + lblTravelDate.Text + "<br/>";
        _mailBody += "No. of Traveller/s: " + lblTravellers.Text + "<br/>";
        _mailBody += "Trip Type: " + lblTripType.Text + "<br/>";
        _mailBody += "Type of Policy: " + lblPolicy.Text + "<br/><br/>";
        
        _mailBody += "<table cellpadding='5' cellspacing='0' border='0' width='546px' class='table_details'>";


        if (dtResults.Rows.Count > 0)
        {
            string _providercompanyid = dtResults.Rows[0]["providercompanyid"].ToString();
            string insurername = dtResults.Rows[0]["InsurerName"].ToString();
            //logo
            string logourl = "/images/public/logo/";
            if (_providercompanyid == "23")
            {
                logourl += "hsbc.png";
                insurername = "HSBC Insurance";
            }
            if (_providercompanyid == "24")
            {
                logourl += "rsa.png";
                insurername = "RSA Insurance";
            }
            else if (_providercompanyid == "29")
            {
                logourl += "liberty.png";
                insurername = "Liberty Insurance";
            }
            else if (_providercompanyid == "30")
            {
                logourl += "etiqa.png";
                insurername = "Etiqa Insurance";
            }
            else if (_providercompanyid == "31")
            {
                logourl += "chartis.png";
                insurername = "Chartis Insurance";
            }
            else if (_providercompanyid == "34")
            {
                logourl += "chinataiping.png";
                insurername = "China Taiping Insurance";
            }
            else if (_providercompanyid == "35")
            {
                logourl += "eq.png";
                insurername = "EQ Insurance";
            }
            else if (_providercompanyid == "36")
            {
                logourl += "ace.png";
                insurername = "ACE Insurance";
            }
            else if (_providercompanyid == "37")
            {
                logourl += "1cover.png";
                insurername = "1Cover Insurance";
            }
            else if (_providercompanyid == "38")
            {
                logourl += "directasia.png";
                insurername = "DirectAsia Insurance";
            }
            _mailBody += "<tr>";
            _mailBody += "<td width='45%'></td>";
            _mailBody += "<td width='55%' align='center' style='background:#e0e0e0; border-bottom:white 1px dashed;'><img src='" + _currentDomainUrl + logourl + "' width='130' style='padding:3px;'/></td>";
            _mailBody += "</tr>";

            //insurer name
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Insurer</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5; color:white;'><strong>" + insurername + "</strong></td>";
            _mailBody += "</tr>";

            //premium
            string premium = "";
            //if (_providercompanyid == "36")
            //{
            //    double _discounted = Convert.ToSingle(dtResults.Rows[0]["annualpremium"].ToString()) * 0.9;
            //    premium = "<small>" + String.Format("${0:0,0.00}", _discounted) + "</small>";
            //    premium += "  <s>" + String.Format("${0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["annualpremium"].ToString())) + "</s>";
            //}
            //else
            //{
                premium = String.Format("${0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["annualpremium"].ToString()));
            //}

            _mailBody += "<tr>";
            _mailBody += "<td align='left' style='background:#d5d5d5' ><strong>Price</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5; color:black; font-size:20px;'><strong>" + premium + "</strong></td>";
            _mailBody += "</tr>";

            //Personal Accident adult
            string PAadult = "";
            float _fPAadult = 0;
            if (dtResults.Rows[0]["DTPD_LessYr70"].ToString() != "")
            {
                _fPAadult = Convert.ToSingle(dtResults.Rows[0]["DTPD_LessYr70"].ToString());
            }

            if (_fPAadult > 0.0f)
            {
                string _PAadultAmount = String.Format("${0:0,0}", _fPAadult);
                PAadult = _PAadultAmount;
            }
            else
            {
                PAadult = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Personal Accident </strong>(adult)</td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + PAadult + "</td>";
            _mailBody += "</tr>";

            //Personal Accident >70
            string PA70 = "";
            float _fPA70 = 0;
            if (dtResults.Rows[0]["DTPD_AboveYr70"].ToString() != "")
            {
                _fPA70 = Convert.ToSingle(dtResults.Rows[0]["DTPD_AboveYr70"].ToString());
            }

            if (_fPA70 > 0.0f)
            {
                string _PA70 = String.Format("${0:0,0}", _fPA70);
                PA70 = _PA70;
            }
            else
            {
                PA70 = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Personal Accident</strong> (> 70)</td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + PA70 + "</td>";
            _mailBody += "</tr>";

            //Double Indemnity adult
            string DIadult = "";
            float _fDIadult = 0;
            if (dtResults.Rows[0]["DIPC_LessYr70"].ToString() != "")
            {
                _fDIadult = Convert.ToSingle(dtResults.Rows[0]["DIPC_LessYr70"].ToString());
            }

            if (_fDIadult > 0.0f)
            {
                string _DIadult = String.Format("${0:0,0}", _fDIadult);
                DIadult = _DIadult;
            }
            else
            {
                DIadult = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Double Indemnity </strong>(adult)</td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + DIadult + "</td>";
            _mailBody += "</tr>";


            //Double Indemnity >70
            string DI70 = "";
            float _fDI70 = 0;
            if (dtResults.Rows[0]["DIPC_AboveYr70"].ToString() != "")
            {
                _fDI70 = Convert.ToSingle(dtResults.Rows[0]["DIPC_AboveYr70"].ToString());
            }

            if (_fDI70 > 0.0f)
            {
                string _DI70 = String.Format("${0:0,0}", _fDI70);
                DI70 = _DI70;
            }
            else
            {
                DI70 = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Double Indemnity </strong>(> 70)</td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + DI70 + "</td>";
            _mailBody += "</tr>";


            //MEd Expenses adult
            string MedExpenseAdult = "";
            float _fMedExpAdult = 0;
            if (dtResults.Rows[0]["MedExp_LessYr70"].ToString() != "")
            {
                _fMedExpAdult = Convert.ToSingle(dtResults.Rows[0]["MedExp_LessYr70"].ToString());
            }

            if (_fMedExpAdult > 0.0f)
            {
                string _MedExpAdult = String.Format("${0:0,0}", _fMedExpAdult);
                MedExpenseAdult = _MedExpAdult;

                if (_providercompanyid == "38")
                {
                    MedExpenseAdult += "<br/>TCM: $300";
                }
                else if (_providercompanyid == "38")
                {
                    MedExpenseAdult += "<br/>TCM: $750";
                }
            }
            else
            {
                MedExpenseAdult = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Medical Expenses </strong>(adult)</td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + MedExpenseAdult + "</td>";
            _mailBody += "</tr>";

            //MEd Expenses > 70
            string MedExpense70 = "";
            float _fMedExp70 = 0;
            if (dtResults.Rows[0]["MedExp_AboveYr70"].ToString() != "")
            {
                _fMedExp70 = Convert.ToSingle(dtResults.Rows[0]["MedExp_AboveYr70"].ToString());
            }

            if (_fMedExp70 > 0.0f)
            {
                string _MedExp70 = String.Format("${0:0,0}", _fMedExp70);
                MedExpense70 = _MedExp70;

                if (_providercompanyid == "38")
                {
                    MedExpense70 += "<br/>TCM: $300";
                }
                else if (_providercompanyid == "36")
                {
                    MedExpense70 += "<br/>TCM: $750";
                }
            }
            else
            {
                MedExpense70 = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Medical Expenses </strong>(> 70)</td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + MedExpense70 + "</td>";
            _mailBody += "</tr>";


            //Emergency Med Evac
            string EmergMedEvac = "";
            float _fEmergMedEvac = 0;
            if (dtResults.Rows[0]["EmMedEval"].ToString() != "")
            {
                _fEmergMedEvac = Convert.ToSingle(dtResults.Rows[0]["EmMedEval"].ToString());
            }

            if (_fEmergMedEvac > 0.0f)
            {
                string _EmergMedEvac = String.Format("${0:0,0}", _fEmergMedEvac);
                EmergMedEvac = _EmergMedEvac;

                if (_providercompanyid == "38")
                {
                    EmergMedEvac += "<br/>(combined cover with Repatriation & Funeral Expense)";
                }

            }
            else
            {
                EmergMedEvac = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Emergency Medical Evacuation </strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + EmergMedEvac + "</td>";
            _mailBody += "</tr>";

            //Repatriation & Funeral Expenses
            string Repatriation = "";
            float _fRepatriation = 0;
            if (dtResults.Rows[0]["BCR"].ToString() != "")
            {
                _fRepatriation = Convert.ToSingle(dtResults.Rows[0]["BCR"].ToString());
            }
            if (dtResults.Rows[0]["Info5"].ToString() == "True")
            {
                Repatriation = "<font color=Red>*as charged</font>";

                if (_providercompanyid == "36")
                {
                    Repatriation = "<font color=Red>Unlimited</font>";
                }

            }
            else
            {
                if (_fRepatriation > 0.0f)
                {
                    string _Repatriation = String.Format("${0:0,0}", _fRepatriation);
                    Repatriation = _Repatriation;

                    if (_providercompanyid == "38")
                    {
                        Repatriation += "<br/>(combined cover with Emergency Medical Evacuation)";
                    }
                }
                else
                {
                    Repatriation = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
                }
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Repatriation & Funeral Expenses</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + Repatriation + "</td>";
            _mailBody += "</tr>";


            //Hospital Income
            string HospitalIncome = "";
            float _fHospitalIncome = 0;
            if (dtResults.Rows[0]["HospIncome"].ToString() != "")
            {
                _fHospitalIncome = Convert.ToSingle(dtResults.Rows[0]["HospIncome"].ToString());
            }

            if (_fHospitalIncome > 0.0f)
            {
                string _HospitalIncome = String.Format("${0:0,0}", _fHospitalIncome);
                HospitalIncome = _HospitalIncome + "/day <br/> max " + String.Format("{0:c0}", int.Parse(dtResults.Rows[0]["Ninfo4"].ToString()));

            }
            else
            {
                HospitalIncome = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Hospital Income</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + HospitalIncome + "</td>";
            _mailBody += "</tr>";

            //Pregnancy
            string Pregnancy = "";
            float _fPregnancy = 0;
            if (dtResults.Rows[0]["NInfo3"].ToString() != "")
            {
                _fPregnancy = Convert.ToSingle(dtResults.Rows[0]["NInfo3"].ToString());
            }

            if (_fPregnancy > 0.0f)
            {
                string _Pregnancy = String.Format("${0:0,0}", _fPregnancy);
                Pregnancy = _Pregnancy;

                if (_providercompanyid == "38")
                {
                    Pregnancy = "Covered under Medical Expenses (adult)";
                }
            }
            else
            {
                Pregnancy = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Pregnancy-Related Illness </strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + Pregnancy + "</td>";
            _mailBody += "</tr>";


            //Overseas Compa Visit
            string OverseasCompVisit = "";
            float _fOverseasCompVisit = 0;
            if (dtResults.Rows[0]["CompassVisit"].ToString() != "")
            {
                _fOverseasCompVisit = Convert.ToSingle(dtResults.Rows[0]["CompassVisit"].ToString());
            }

            if (_fOverseasCompVisit > 0.0f)
            {
                string _OverseasCompVisit = String.Format("${0:0,0}", _fOverseasCompVisit);
                OverseasCompVisit = _OverseasCompVisit;

            }
            else
            {
                OverseasCompVisit = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Overseas Compassionate Visit</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + OverseasCompVisit + "</td>";
            _mailBody += "</tr>";


            //Child Guard
            string ChildGuard = "";
            float _fChildGuard = 0;
            if (dtResults.Rows[0]["ChildCare"].ToString() != "")
            {
                _fChildGuard = Convert.ToSingle(dtResults.Rows[0]["ChildCare"].ToString());
            }

            if (_fChildGuard > 0.0f)
            {
                string _ChildGuard = String.Format("${0:0,0}", _fOverseasCompVisit);
                ChildGuard = _ChildGuard;

            }
            else
            {
                ChildGuard = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Child Guard</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + ChildGuard + "</td>";
            _mailBody += "</tr>";


            //Personal Liablity
            string PersonalLiability = "";
            float _fPersonalLiability = 0;
            if (dtResults.Rows[0]["PersonalLiability"].ToString() != "")
            {
                _fPersonalLiability = Convert.ToSingle(dtResults.Rows[0]["PersonalLiability"].ToString());
            }

            if (_fPersonalLiability > 0.0f)
            {
                string _PersonalLiability = String.Format("${0:0,0}", _fPersonalLiability);
                PersonalLiability = _PersonalLiability;

            }
            else
            {
                PersonalLiability = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Personal Liability</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + PersonalLiability + "</td>";
            _mailBody += "</tr>";


            //Loss Baggage & Personal Effects
            string LossBaggage = "";
            float _fLossBaggage = 0;
            if (dtResults.Rows[0]["BagPerEffect"].ToString() != "")
            {
                _fLossBaggage = Convert.ToSingle(dtResults.Rows[0]["BagPerEffect"].ToString());
            }

            if (_fLossBaggage > 0.0f)
            {
                string _LossBaggage = String.Format("${0:0,0}", _fLossBaggage);
                LossBaggage = _LossBaggage;

                if (_providercompanyid == "38")
                {
                    LossBaggage += "<br/>($500 per article/laptop/mobile phone or PDA)";
                }

            }
            else
            {
                LossBaggage = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Loss Baggage & Personal Effects</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + LossBaggage + "</td>";
            _mailBody += "</tr>";

            //OverseasBaggage
            string OverseasBaggage = "";
            float _fOverseasBaggage = 0;
            if (dtResults.Rows[0]["BagDelay"].ToString() != "")
            {
                _fOverseasBaggage = Convert.ToSingle(dtResults.Rows[0]["BagDelay"].ToString());
            }

            if (_fOverseasBaggage > 0.0f)
            {
                string _OverseasBaggage = String.Format("${0:0,0}", _fOverseasBaggage) + "/" + dtResults.Rows[0]["Ninfo5"].ToString() + "-hour delay";
                _OverseasBaggage += "<br/> max " + String.Format("{0:c0}", int.Parse(dtResults.Rows[0]["Ninfo6"].ToString()));

                OverseasBaggage = _OverseasBaggage;

                if (_providercompanyid == "38")
                {
                    OverseasBaggage = String.Format("{0:c0}", int.Parse(dtResults.Rows[0]["Ninfo6"].ToString()));
                }

            }
            else
            {
                OverseasBaggage = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Overseas Baggage Delay</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + OverseasBaggage + "</td>";
            _mailBody += "</tr>";


            //Trip Cancellation
            string TripCancellation = "";
            float _fTripCancellation = 0;
            if (dtResults.Rows[0]["DepositTripCancel"].ToString() != "")
            {
                _fTripCancellation = Convert.ToSingle(dtResults.Rows[0]["DepositTripCancel"].ToString());
            }

            if (_fTripCancellation > 0.0f)
            {
                string _TripCancellation = String.Format("${0:0,0}", _fTripCancellation);
                TripCancellation = _TripCancellation;

            }
            else
            {
                TripCancellation = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Trip Cancellation</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + TripCancellation + "</td>";
            _mailBody += "</tr>";


            //Trip Curtailment
            string TripCurtailment = "";
            float _fTripCurtailment = 0;
            if (dtResults.Rows[0]["Curtailment"].ToString() != "")
            {
                _fTripCurtailment = Convert.ToSingle(dtResults.Rows[0]["Curtailment"].ToString());
            }

            if (_fTripCurtailment > 0.0f)
            {
                string _TripCurtailment = String.Format("${0:0,0}", _fTripCurtailment);
                TripCurtailment = _TripCurtailment;

                if (_providercompanyid == "38")
                {
                    TripCurtailment = TripCancellation;
                }

            }
            else
            {
                TripCurtailment = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Trip Curtailment</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + TripCurtailment + "</td>";
            _mailBody += "</tr>";


            //Overseas Travel Delay
            string OverseasTD = "";
            float _fOverseasTD = 0;
            if (dtResults.Rows[0]["TravelDelay"].ToString() != "")
            {
                _fOverseasTD = Convert.ToSingle(dtResults.Rows[0]["TravelDelay"].ToString());
            }

            if (_fOverseasTD > 0.0f)
            {
                string _OverseasTD = String.Format("${0:0,0}", _fOverseasTD) + "/" + dtResults.Rows[0]["Ninfo7"].ToString() + "-hour delay";
                _OverseasTD += "<br/> max " + String.Format("{0:c0}", int.Parse(dtResults.Rows[0]["Ninfo8"].ToString()));
                OverseasTD = _OverseasTD;

                if (_providercompanyid == "38")
                {
                    OverseasTD = "$1,000 <br/>($100 per 6 hrs *)<br/>* $50 per 6 hrs for Jetstar and Tiger"; ;
                }

            }
            else
            {
                OverseasTD = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Overseas Travel Delay</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + OverseasTD + "</td>";
            _mailBody += "</tr>";

            //Missed Travel Connection
            string MissTravelConn = "";
            float _fMissTravelConn = 0;
            if (dtResults.Rows[0]["MissTravelConnection"].ToString() != "")
            {
                _fMissTravelConn = Convert.ToSingle(dtResults.Rows[0]["MissTravelConnection"].ToString());
            }

            if (_fMissTravelConn > 0.0f)
            {
                string _MissTravelConn = String.Format("${0:0,0}", _fMissTravelConn);
                MissTravelConn = _MissTravelConn;

            }
            else
            {
                MissTravelConn = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Missed Travel Connection</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + MissTravelConn + "</td>";
            _mailBody += "</tr>";


            //Travel Overbooked
            string TravelOverbook = "";
            float _fTravelOverbook = 0;
            if (dtResults.Rows[0]["TravelOverBook"].ToString() != "")
            {
                _fTravelOverbook = Convert.ToSingle(dtResults.Rows[0]["TravelOverBook"].ToString());
            }

            if (_fTravelOverbook > 0.0f)
            {
                string _TravelOverbook = String.Format("${0:0,0}", _fTravelOverbook);
                TravelOverbook = _TravelOverbook;

            }
            else
            {
                TravelOverbook = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Travel Overbooked</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + TravelOverbook + "</td>";
            _mailBody += "</tr>";


            //Loss of Personal Money
            string LossMoney = "";
            float _fLossMoney = 0;
            if (dtResults.Rows[0]["PersonalMoney"].ToString() != "")
            {
                _fLossMoney = Convert.ToSingle(dtResults.Rows[0]["PersonalMoney"].ToString());
            }

            if (_fLossMoney > 0.0f)
            {
                string _LossMoney = String.Format("${0:0,0}", _fLossMoney);
                LossMoney = _LossMoney;

            }
            else
            {
                LossMoney = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Loss of Personal Money</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + LossMoney + "</td>";
            _mailBody += "</tr>";


            //Loss of Travel Documents
            string LossTravelDoc = "";
            float _fLossTravelDoc = 0;
            if (dtResults.Rows[0]["TravelDoc"].ToString() != "")
            {
                _fLossTravelDoc = Convert.ToSingle(dtResults.Rows[0]["TravelDoc"].ToString());
            }

            if (_fLossTravelDoc > 0.0f)
            {
                string _LossTravelDoc = String.Format("${0:0,0}", _fLossTravelDoc);
                LossTravelDoc = _LossTravelDoc;

            }
            else
            {
                LossTravelDoc = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Loss of Travel Documents</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + LossTravelDoc + "</td>";
            _mailBody += "</tr>";


            //Closure of Travel Agency
            string ClosureAgency = "";
            float _fClosureAgency = 0;
            if (dtResults.Rows[0]["Info3"].ToString() != "")
            {
                _fClosureAgency = Convert.ToSingle(dtResults.Rows[0]["Info3"].ToString());
            }

            if (_fClosureAgency > 0.0f)
            {
                string _ClosureAgency = String.Format("${0:0,0}", _fClosureAgency);
                ClosureAgency = _ClosureAgency;

            }
            else
            {
                ClosureAgency = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Closure of Travel Agency</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + ClosureAgency + "</td>";
            _mailBody += "</tr>";


            //Home Contents
            string HomeContents = "";
            float _fHomeContents = 0;
            if (dtResults.Rows[0]["FBHCP"].ToString() != "")
            {
                _fHomeContents = Convert.ToSingle(dtResults.Rows[0]["FBHCP"].ToString());
            }

            if (_fHomeContents > 0.0f)
            {
                string _HomeContents = String.Format("${0:0,0}", _fHomeContents);
                HomeContents = _HomeContents;

                if (_providercompanyid == "23")
                {
                    if (Session["TripType"].ToString() == "A")
                    {
                        HomeContents = "Optional";
                    }
                }
            }
            else
            {
                HomeContents = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Home Contents Protection</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + HomeContents + "</td>";
            _mailBody += "</tr>";


            //Rental Vehicle
            string RentalVehicle = "";
            float _fRentalVehicle = 0;
            if (dtResults.Rows[0]["ACRR"].ToString() != "")
            {
                _fRentalVehicle = Convert.ToSingle(dtResults.Rows[0]["ACRR"].ToString());
            }

            if (_fRentalVehicle > 0.0f)
            {
                string _RentalVehicle = String.Format("${0:0,0}", _fRentalVehicle);
                RentalVehicle = _RentalVehicle;


            }
            else
            {
                RentalVehicle = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Rental Vehicle Excess</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + RentalVehicle + "</td>";
            _mailBody += "</tr>";


            //Hijack
            string Hijack = "";
            float _fHijack = 0;
            if (dtResults.Rows[0]["Terrorism"].ToString() != "")
            {
                _fHijack = Convert.ToSingle(dtResults.Rows[0]["Terrorism"].ToString());
            }

            if (_fHijack > 0.0f)
            {
                string _Hijack = String.Format("${0:0,0}", _fHijack) + "/" + dtResults.Rows[0]["Info1"].ToString() + "-hour";
                _Hijack += "<br/> max " + String.Format("{0:c0}", int.Parse(dtResults.Rows[0]["Info2"].ToString()));
                Hijack = _Hijack;

            }
            else
            {
                Hijack = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Hijack</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + Hijack + "</td>";
            _mailBody += "</tr>";

            //Kidnap / Hostage
            string Kidnap = "";
            float _fKidnap = 0;
            if (dtResults.Rows[0]["KidnapHostage"].ToString() != "")
            {
                _fKidnap = Convert.ToSingle(dtResults.Rows[0]["KidnapHostage"].ToString());
            }

            if (_fKidnap > 0.0f)
            {
                string _Kidnap = String.Format("${0:0,0}", _fKidnap);
                Kidnap = _Kidnap;

            }
            else
            {
                Kidnap = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Kidnap</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + Kidnap + "</td>";
            _mailBody += "</tr>";

            //Emergency Tel Charges
            string EmtelCharge = "";
            float _fEmtelCharge = 0;
            if (dtResults.Rows[0]["EmTelCharge"].ToString() != "")
            {
                _fEmtelCharge = Convert.ToSingle(dtResults.Rows[0]["EmTelCharge"].ToString());
            }

            if (dtResults.Rows[0]["Info6"].ToString() != "" && dtResults.Rows[0]["Info6"].ToString() == "True")
            {
                EmtelCharge = "<font color='red'>*actual cost</font>";
            }
            else
            {
                if (_fEmtelCharge > 0.0f)
                {
                    string _EmtelCharge = String.Format("${0:0,0}", _fEmtelCharge);
                    EmtelCharge = _EmtelCharge;

                }
                else
                {
                    EmtelCharge = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
                }
            }

            _mailBody += "<tr>";
            _mailBody += "<td><strong>Emergency Telephone Charges</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + EmtelCharge + "</td>";
            _mailBody += "</tr>";


            //View Policy Wordings
            string _policyId = dtResults.Rows[0]["NInfo1"].ToString();

            ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
            ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

            _policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

            string docurl = _currentDomainUrl + _policydoc.UploadPath.Remove(0, 1);
            string viewpolicywordings = "<a href='" + docurl + "' ><img src='" + _currentDomainUrl + "/images/icon/pdf.png'  alt='policy wordings' width='23' alt='NA' border='0'/></a>";

            _mailBody += "<tr>";
            _mailBody += "<td><strong>View Policy Wordings</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + viewpolicywordings + "</td>";
            _mailBody += "</tr>";

        }

        _mailBody += "</table>";
        _mailBody += "<br/><br/>You are also able to view this quote on our website by clicking on the link below. <br/><br/>";
        _mailBody += " <a href='http://www.comparexpress.com/travel-insurance/'>CompareXpress.com</a> <br/><br/>";

        _mailBody += "</td></tr>";
        _mailBody += "<tr><td id='email_footer'><a href='http://www.comparexpress.com' target='_blank'><img src='" + _currentDomainUrl + "/images/email/footer_quote.png' alt='CompareXpress - Partners' width='596' height='174' border='0' /></a>";
        _mailBody += "</td></tr></table>";

        _mailBody += "<hr />";
        _mailBody += "This Quote is subject to the insurer's final confirmation and coverage is only effective when the <br/>";
        _mailBody += "insurer has accepted the risk.<br/>";
        _mailBody += "<br /><i>This is a computer-generated email. Please do not reply to this email.</i>";
        _mailBody += "<hr />";
        _mailBody += "</center></body>";

        if (MyMailManager.SendCRMMessage(_emailTo, _emailSubject, _mailBody))
        {
            _retVal = true;
        }
        else
        {
            _retVal = false;
        }

        return _retVal;
    }

    private void TAUserOptionLog(bool isBuyNow, bool isCallMe, bool isEmailMe)
    {
        TAUserOption tauseroption = new TAUserOption();
        TAUserOptionDB tauseroptiondb = new TAUserOptionDB();

        tauseroption.TAUserOptionId = 0;
        tauseroption.TAId = Convert.ToInt64(Session[General.TAId].ToString());
        tauseroption.IsBuyNow = isBuyNow;
        tauseroption.IsCallMe = isCallMe;
        tauseroption.IsEmailMe = isEmailMe;
        tauseroption.IsEmailThis = false;
        tauseroption.RecipientName = "";
        tauseroption.RecipientEmailAddress = "";
        tauseroption.ViewedDetailId = 0;
        tauseroption.RefCEUserId = 0;

        if (Session[General.UserId] != null)
        {
            if (Session[General.UserId].ToString() != "")
                tauseroption.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
        }

        tauseroptiondb.Insert(tauseroption);
    }

    protected void btnBuyNow_Click(object sender, EventArgs e)
    {
        Session[General.TAUserName] = txtFullName.Text;
        Session[General.TAPhoneNo] = txtMobileNo.GetPhoneNo();
        Session[General.TAEmail] = txtEmail.Text;

        string _providerID = "";
        _providerID = inputProviderId.Value.Trim();

        Session[CE.Global.General.TAId] = inputTAId.Value.Trim().ToString();
        Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["TAFromSummary"] = "0";
        TAUserOptionLog(true, false, false);

        Int64 _UserId = 0;
        if (Session[General.UserId] != null)
        {
            _UserId = Convert.ToInt64(Session[General.UserId].ToString());
        }

        string CoverType = inputPlanType.Value.Trim().ToString();
        string PlanName = inputPlanName.Value.Trim().ToString();
        Int64 TAId = Convert.ToInt64(inputTAId.Value.Trim().ToString());
        Int64 _resultId = Convert.ToInt64(inputResultId.Value.ToString());

        float TotalPremium = 0;
        TotalPremium = float.Parse(inputPremium.Value.Trim().ToString());

        //if (_providerID == "36")
        //{
        //    TotalPremium = (float)(TotalPremium * 0.9);
        //}

        if (Session[General.TAId] != null)
            TAId = Convert.ToInt64(Session[General.TAId]);

        LogUserSelectHistory(CoverType, _resultId, Convert.ToInt64(_providerID));

        //update total premium field
        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearchDB _taapplicantsearchdbBuy = new TAApplicantSearchDB();

        Int64 UpdatedId = _taapplicantsearchdbBuy.UpdatePremium(TAId, TotalPremium, _resultId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()), PlanName);

        Session[General.TAResultId] = _resultId;

        if (_UserId == 0 || Convert.ToInt32(Session[CE.Global.General.UserTypeId]) == Convert.ToInt32(CE.Global.CEUserType.Provider))
        {
            _taapplicantsearchdb.UpdateProfileDetails(TAId, txtFullName.Text, txtMobileNo.GetPhoneNo(), txtEmail.Text);
        }

        if (_providerID == "29")
        {
            if (Request.QueryString["pid"] != null)
            {
                if (Request.QueryString["pid"].ToString() != "")
                {
                    Response.Redirect("~/travel-insurance/proposalforms/liberty_proposal_form.aspx?pid=" + Request.QueryString["pid"].ToString());
                }
                else
                {
                    Response.Redirect("~/travel-insurance/proposalforms/liberty_proposal_form.aspx");
                }
            }
            else
            {
                Response.Redirect("~/travel-insurance/proposalforms/liberty_proposal_form.aspx");
            }
        }
        else if (_providerID == "30")
        {
            if (Request.QueryString["pid"] != null)
            {
                if (Request.QueryString["pid"].ToString() != "")
                {
                    Response.Redirect("~/travel-insurance/proposalforms/etiqa_proposal_form.aspx?pid=" + Request.QueryString["pid"].ToString());
                }
                else
                {
                    Response.Redirect("~/travel-insurance/proposalforms/etiqa_proposal_form.aspx");
                }
            }
            else
            {
                Response.Redirect("~/travel-insurance/proposalforms/etiqa_proposal_form.aspx");
            }
        }
        else if (_providerID == "35")
        {
            Response.Redirect("~/travel-insurance/proposalforms/eq_proposal_form.aspx");
        }
        else if (_providerID == "36")
        {
            Session["acesearch"] = null;
            if (Request.QueryString["pid"] != null)
            {
                if (Request.QueryString["pid"].ToString() != "")
                {
                    Response.Redirect("~/travel-insurance/proposalforms/ace_proposal_form.aspx?pid=" + Request.QueryString["pid"].ToString());
                }
                else
                {
                    Response.Redirect("~/travel-insurance/proposalforms/ace_proposal_form.aspx");
                }
            }
            else
            {
                Response.Redirect("~/travel-insurance/proposalforms/ace_proposal_form.aspx");
            }
        }

    }

    protected void btnEmailMe_Click(object sender, EventArgs e)
    {
        Session[General.TAUserName] = txtFullName.Text;
        Session[General.TAPhoneNo] = txtMobileNo.GetPhoneNo();
        Session[General.TAEmail] = txtEmail.Text;

        string _providerID = "";
        _providerID = inputProviderId.Value.Trim();

        Session[CE.Global.General.TAId] = inputTAId.Value.Trim().ToString();
        Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["TAFromSummary"] = "0";

        if (SendMailToUser())
        {
            TAUserOptionLog(false, false, true);
            Response.Redirect("email-usermessage.aspx");
        }

    }

    protected void btnEmailThis_Click(object sender, EventArgs e)
    {
        Session[General.TAUserName] = txtFullName.Text;
        Session[General.TAPhoneNo] = txtMobileNo.GetPhoneNo();
        Session[General.TAEmail] = txtEmail.Text;

        string _providerID = "";
        _providerID = inputProviderId.Value.Trim();

        Session[CE.Global.General.TAId] = inputTAId.Value.Trim().ToString();
        Session[CE.Global.General.TAResultId] = inputResultId.Value.Trim().ToString();
        Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["TAFromSummary"] = "0";

        Response.Redirect("email-this.aspx");
    }

    protected void btnBack_Click(object sender, EventArgs e)
    {
        //Response.Redirect("results.aspx");
        //BackToResultsMainPage();
        BackToSearchPage();
    }

    private Int32 GetPromoDiscount(string providerid)
    {
        Int32 Discount = 0;
        MyDatabase _db = new MyDatabase();
        string strSql = "SELECT ItemType FROM tblCXPromotion WHERE ProviderCompanyId = " + providerid + " AND PromotionType = 600 AND dbo.fn_getUTCDateTime() BETWEEN StartDate AND EndDate";
        DataTable _dt = new DataTable("aTable");
        _dt = _db.GetDataTable(strSql);

        if (_dt != null && _dt.Rows.Count > 0)
        {
            Discount = Convert.ToInt32(_dt.Rows[0]["ItemType"].ToString());
        }

        return Discount;

    }

    protected void ddlCoverage_SelectedIndexChange(object sender, EventArgs e)
    {
        lnkbtnPrev.Enabled = false;
        lnkbtnPrevBottom.Enabled = false;

        lnkbtnPage1.Enabled = false;
        lnkbtnPage1Bottom.Enabled = false;
                
        lnkbtnNex.Enabled = true;
        lnkbtnNexBottom.Enabled = true;

        lnkbtnPage2.Enabled = true;
        lnkbtnPage2Bottom.Enabled = true;

        GetQuotesAgain(ddlCoverage.SelectedValue, 1);
        ResultsQuotesDataBind();
    }

    private void GetQuotesAgain(string coverage, int pagenum)
    {
        //if (Cache["TAResultsQuotes" + Session[General.TAId].ToString()] == null)
        GetTempResultTable(coverage);

        DataView dv = new DataView((DataTable)Cache["TAResultsQuotes" + Session[General.TAId].ToString()]);

        if (dv.Count > 0)
        {
            RowCount = dv.Count;

            if (Request.UrlReferrer != null)
            {
                Session["DefaultSort"] = null;
                Session["SortExp"] = null;

                dv.Sort = "AnnualPremium ASC";

                Cache["TAResultsQuotes" + Session[General.TAId].ToString()] = dv.ToTable();

            }

            string sQueryString = "";

            if (pagenum == 1)
            {
                for (int i = 0; i < dv.ToTable().Rows.Count; i++)
                {
                    if (i == 7)
                    {
                        break;
                    }

                    string skey = dv.ToTable().Rows[i]["TAInsID"].ToString();
                    sQueryString += skey + ",";
                }
            }
            else //2nd page
            {
                for (int i = 7; i < dv.ToTable().Rows.Count; i++)
                {
                    if (i == 14)
                    {
                        break;
                    }

                    string skey = dv.ToTable().Rows[i]["TAInsID"].ToString();
                    sQueryString += skey + ",";
                }
 
            }

            Session["TASelected"] = sQueryString;

        }

    }

    private void GetTempResultTable(string CoverageLevel)
    {
        string CoverType = "";
        Int32 Duration = 0;
        string Trip = "";
        Int64 AreaId = 0;
        Int64 CountryId = 0;
        Int32 AdultAge = 0;
        Int32 ChildAge = 0;
        Int64 TAId = 0;
        Int32 NoOfAdults = 0;
        Int32 NoOfChilds = 0;

        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();

        if (Session[General.TAId] != null && Session[General.TAId].ToString() != "")
            TAId = Convert.ToInt64(Session[General.TAId].ToString());
        else
        {
            this.Page_Load(this, null);
        }

        _taapplicantsearch = _taapplicantsearchdb.GetTAApplicantSearchItem(TAId);

        if (_taapplicantsearch != null)
        {
            CoverType = _taapplicantsearch.PlanType;
            Duration = _taapplicantsearch.Duration;
            AreaId = _taapplicantsearch.AreaID;
            CountryId = _taapplicantsearch.CountryID;
            AdultAge = _taapplicantsearch.AdultAge;
            ChildAge = _taapplicantsearch.ChildAge;

            if (CoverageLevel == "")
            {
                CoverageLevel = _taapplicantsearch.CoverageLevel;
            }

            Trip = _taapplicantsearch.TripType;
            NoOfAdults = _taapplicantsearch.NoofAdults;
            NoOfChilds = _taapplicantsearch.NoofChilds;
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();


            TAQuoteResultDB _taquoteresultdb = new TAQuoteResultDB();

            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
             Convert.ToInt32(CE.Global.CEUserType.Provider) && Session[CE.Global.General.ProviderCompanyId] != null)
            {
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplayByProvider(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()), NoOfAdults, NoOfChilds, TAId);

            }
            else if (_taapplicantsearch.Ninfo3 != 0)
            {
                //with Promo per Provider
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplayByProviderWithPromo(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, _taapplicantsearch.Ninfo3, NoOfAdults, NoOfChilds, TAId);
            }
            else
            {
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplay(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Trip, NoOfAdults, NoOfChilds, TAId);

            }
            // }


            //update tbltaapplicantsearch
            UpdateCoverage(TAId, CoverageLevel);

            RowCount = _dtResult.Rows.Count;

            DataView dv = new DataView(_dtResult);
            string strSortExpress = "AnnualPremium ASC";

            dv.Sort = strSortExpress;
            Cache["TAResultsQuotes" + Session[General.TAId].ToString()] = dv.ToTable();

        }
        else
        {
            this.Page_Load(this, null);

        }

    }

    private Int64 UpdateCoverage(Int64 TAAppSeaId, string coverage)
    {
        MyDatabase _db = new MyDatabase();
        Int64 _result = -1;
        string _spName = "sprocTAApplicantSearchUpdateCoverage";

        SortedList _sPara = new SortedList();
        _sPara.Add("@TAAppSeaId", TAAppSeaId);
        _sPara.Add("@CoverageLevel", coverage);


        _result = _db.ExecuteSP(_spName, _sPara);

        return _result;

    }

    protected void GetResultsPerPage(object sender, EventArgs e)
    {
        if (!lnkbtnPage1.Enabled)
        {
            lnkbtnPrev.Enabled = true;
            lnkbtnPrevBottom.Enabled = true;
            lnkbtnPage1.Enabled = true;
            lnkbtnPage1Bottom.Enabled = true;

            lnkbtnNex.Enabled = false;
            lnkbtnNexBottom.Enabled = false;
            lnkbtnPage2.Enabled = false;
            lnkbtnPage2Bottom.Enabled = false;

            GetQuotesAgain(ddlCoverage.SelectedValue, 2);
            ResultsQuotesDataBind();

        }
        else
        {
            lnkbtnPrev.Enabled = false;
            lnkbtnPrevBottom.Enabled = false;
            lnkbtnPage1.Enabled = false;
            lnkbtnPage1Bottom.Enabled = false;

            lnkbtnNex.Enabled = true;
            lnkbtnNexBottom.Enabled = true;
            lnkbtnPage2.Enabled = true;
            lnkbtnPage2Bottom.Enabled = true;

            GetQuotesAgain(ddlCoverage.SelectedValue, 1);
            ResultsQuotesDataBind();

        }
 
    }

}
